Skip to content

Commit bb3d2a0

Browse files
committed
Merge branch 'release/2.0.0'
2 parents 9c8cd95 + 417723d commit bb3d2a0

14 files changed

Lines changed: 81 additions & 65 deletions

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
77
## [Unreleased][unreleased]
88
-
99

10+
## [2.0.0] - 2022-01-10
11+
### Added
12+
- Added `DateTimeTrait::create_from_interface`.
13+
14+
### Removed
15+
- Removed `DateTime::create_from_mutable`.
16+
- Removed `DateTimeImmutable::create_from_mutable`.
17+
1018
## [1.2.2] - 2021-08-26
1119
- Added the character `p` to the date format characters list which was added in PHP 8.
1220

@@ -41,7 +49,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
4149
## 1.0.0
4250
- First release.
4351

44-
[unreleased]: https://github.com/pronamic/wp-datetime/compare/1.2.2...HEAD
52+
[unreleased]: https://github.com/pronamic/wp-datetime/compare/2.0.0...HEAD
53+
[2.0.0]: https://github.com/pronamic/wp-datetime/compare/1.2.2...2.0.0
4554
[1.2.2]: https://github.com/pronamic/wp-datetime/compare/1.2.1...1.2.2
4655
[1.2.1]: https://github.com/pronamic/wp-datetime/compare/1.2.0...1.2.1
4756
[1.2.0]: https://github.com/pronamic/wp-datetime/compare/1.1.1...1.2.0

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ Source: https://developer.wordpress.org/reference/functions/date_i18n/#comment-2
2929

3030
* https://github.com/woocommerce/woocommerce/blob/3.3.5/includes/class-wc-datetime.php
3131
* https://github.com/Rarst/wpdatetime
32+
33+
[![Pronamic - Work with us](https://github.com/pronamic/brand-resources/blob/main/banners/pronamic-work-with-us-leaderboard-728x90%404x.png)](https://www.pronamic.eu/contact/)

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
"phpmd/phpmd": "^2.9",
3030
"phpunit/phpunit": "^5.7 || ^6.0",
3131
"pronamic/wp-coding-standards": "^1.0",
32-
"roots/wordpress": "^5.6",
32+
"roots/wordpress": "^5.8",
3333
"squizlabs/php_codesniffer": "^3.5",
3434
"vlucas/phpdotenv": "^2.0",
35-
"wp-phpunit/wp-phpunit": "^5.6"
35+
"wp-phpunit/wp-phpunit": "^5.8",
36+
"yoast/phpunit-polyfills": "^1.0"
3637
},
3738
"scripts": {
3839
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover build/logs/clover.xml --coverage-text",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wp-datetime",
3-
"version": "1.2.2",
3+
"version": "2.0.0",
44
"description": "WordPress DateTime library.",
55
"repository": {
66
"type": "git",

pronamic-datetime.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin URI: https://www.pronamic.eu/plugins/pronamic-datetime/
55
* Description: WordPress DateTime library.
66
*
7-
* Version: 1.2.0
7+
* Version: 2.0.0
88
* Requires at least: 4.7
99
*
1010
* Author: Pronamic
@@ -18,7 +18,7 @@
1818
* GitHub URI: https://github.com/pronamic/wp-datetime
1919
*
2020
* @author Pronamic <info@pronamic.eu>
21-
* @copyright 2005-2021 Pronamic
21+
* @copyright 2005-2022 Pronamic
2222
* @license GPL-3.0-or-later
2323
* @package Pronamic\WordPress\Pay
2424
*/

src/DateTime.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Date time
44
*
55
* @author Pronamic <info@pronamic.eu>
6-
* @copyright 2005-2021 Pronamic
6+
* @copyright 2005-2022 Pronamic
77
* @license GPL-3.0-or-later
88
* @package Pronamic\WordPress\DateTime
99
* @see https://github.com/woocommerce/woocommerce/blob/3.3.4/includes/class-wc-datetime.php
@@ -21,29 +21,4 @@
2121
*/
2222
class DateTime extends \DateTime implements DateTimeInterface {
2323
use DateTimeTrait;
24-
25-
/**
26-
* Overrides upstream method to correct returned instance type to the inheriting one.
27-
*
28-
* {@inheritdoc}
29-
*
30-
* @param \DateTimeImmutable $object Object.
31-
* @return self
32-
*/
33-
public static function createFromImmutable( $object ) {
34-
return self::create_from_immutable( $object );
35-
}
36-
37-
/**
38-
* Create from immutable.
39-
*
40-
* @link https://www.php.net/manual/en/datetimeimmutable.createfrommutable.php
41-
* @param \DateTimeImmutable $object The immutable DateTimeImmutable object that needs to be converted to a mutable version.
42-
* @return self
43-
*/
44-
public static function create_from_immutable( \DateTimeImmutable $object ) {
45-
$instance = new self( '@' . $object->getTimestamp() );
46-
47-
return $instance->setTimezone( $object->getTimezone() );
48-
}
4924
}

src/DateTimeImmutable.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Date time immutable
44
*
55
* @author Pronamic <info@pronamic.eu>
6-
* @copyright 2005-2021 Pronamic
6+
* @copyright 2005-2022 Pronamic
77
* @license GPL-3.0-or-later
88
* @package Pronamic\WordPress\DateTime
99
* @see https://github.com/woocommerce/woocommerce/blob/3.3.4/includes/class-wc-datetime.php
@@ -21,29 +21,4 @@
2121
*/
2222
class DateTimeImmutable extends \DateTimeImmutable implements DateTimeInterface {
2323
use DateTimeTrait;
24-
25-
/**
26-
* Overrides upstream method to correct returned instance type to the inheriting one.
27-
*
28-
* {@inheritdoc}
29-
*
30-
* @param \DateTime $object Object.
31-
* @return self
32-
*/
33-
public static function createFromMutable( $object ) {
34-
return self::create_from_mutable( $object );
35-
}
36-
37-
/**
38-
* Create from mutable.
39-
*
40-
* @link https://www.php.net/manual/en/datetimeimmutable.createfrommutable.php
41-
* @param \DateTime $object The mutable DateTime object that you want to convert to an immutable version.
42-
* @return self
43-
*/
44-
public static function create_from_mutable( \DateTime $object ) {
45-
$instance = new self( '@' . $object->getTimestamp() );
46-
47-
return $instance->setTimezone( $object->getTimezone() );
48-
}
4924
}

src/DateTimeInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Date time interface
44
*
55
* @author Pronamic <info@pronamic.eu>
6-
* @copyright 2005-2021 Pronamic
6+
* @copyright 2005-2022 Pronamic
77
* @license GPL-3.0-or-later
88
* @package Pronamic\WordPress\DateTime
99
* @see https://github.com/woocommerce/woocommerce/blob/3.3.4/includes/class-wc-datetime.php

src/DateTimeTrait.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Date time trait
44
*
55
* @author Pronamic <info@pronamic.eu>
6-
* @copyright 2005-2021 Pronamic
6+
* @copyright 2005-2022 Pronamic
77
* @license GPL-3.0-or-later
88
* @package Pronamic\WordPress\DateTime
99
* @see https://github.com/woocommerce/woocommerce/blob/3.3.4/includes/class-wc-datetime.php
@@ -293,4 +293,16 @@ public static function create_from_format( $format, $time, \DateTimeZone $timezo
293293

294294
return $wp_date_time;
295295
}
296+
297+
/**
298+
* Create from interface.
299+
*
300+
* @link https://www.php.net/manual/en/datetime.createfrominterface.php
301+
* @link https://php.watch/versions/8.0/datetime-immutable-createfrominterface
302+
* @param \DateTimeInterface $object The mutable DateTime object that you want to convert to an immutable version.
303+
* @return self
304+
*/
305+
public static function create_from_interface( \DateTimeInterface $object ) {
306+
return new self( $object->format('Y-m-d H:i:s.u'), $object->getTimezone() );
307+
}
296308
}

src/DateTimeZone.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Date time zone
44
*
55
* @author Pronamic <info@pronamic.eu>
6-
* @copyright 2005-2021 Pronamic
6+
* @copyright 2005-2022 Pronamic
77
* @license GPL-3.0-or-later
88
* @package Pronamic\WordPress\DateTime
99
* @see https://github.com/woocommerce/woocommerce/blob/3.3.4/includes/class-wc-datetime.php

0 commit comments

Comments
 (0)