@@ 9-26 (lines=18) @@ | ||
6 | */ |
|
7 | namespace Spindle\Types\Polyfill; |
|
8 | ||
9 | class DateTime extends \DateTime implements DateTimeInterface |
|
10 | { |
|
11 | static function createFromFormat($format, $time, /* \DateTimeZone */ $timezone=null) |
|
12 | { |
|
13 | if ($timezone) { |
|
14 | $dateTime = \date_create_from_format($format, $time, $timezone); |
|
15 | } else { |
|
16 | $dateTime = \date_create_from_format($format, $time); |
|
17 | } |
|
18 | return new static($dateTime->format('c')); |
|
19 | } |
|
20 | ||
21 | static function __set_state(array $array) |
|
22 | { |
|
23 | $dateTime = parent::__set_state($array); |
|
24 | return new static($dateTime->format('c')); |
|
25 | } |
|
26 | } |
|
27 |
@@ 11-28 (lines=18) @@ | ||
8 | ||
9 | //@codeCoverageIgnoreStart |
|
10 | if (class_exists('DateTimeImmutable', false)) { |
|
11 | class DateTimeImmutable extends \DateTimeImmutable implements DateTimeInterface |
|
12 | { |
|
13 | static function createFromFormat($format, $time, /* \DateTimeZone */ $timezone=null) |
|
14 | { |
|
15 | if ($timezone) { |
|
16 | $dateTime = \date_create_from_format($format, $time, $timezone); |
|
17 | } else { |
|
18 | $dateTime = \date_create_from_format($format, $time); |
|
19 | } |
|
20 | return new static($dateTime->format('c')); |
|
21 | } |
|
22 | ||
23 | static function __set_state(array $array) |
|
24 | { |
|
25 | $dateTime = parent::__set_state($array); |
|
26 | return new static($dateTime->format('c')); |
|
27 | } |
|
28 | } |
|
29 | } else { |
|
30 | class DateTimeImmutable extends \DateTime implements DateTimeInterface |
|
31 | { |