| @@ 7-19 (lines=13) @@ | ||
| 4 | ||
| 5 | namespace Linio\Type; |
|
| 6 | ||
| 7 | class Date extends \DateTime |
|
| 8 | { |
|
| 9 | public function __construct(string $time = 'now', \DateTimeZone $timezone = null) |
|
| 10 | { |
|
| 11 | parent::__construct($time, $timezone); |
|
| 12 | $this->setTime(0, 0, 0); |
|
| 13 | } |
|
| 14 | ||
| 15 | public static function createFromDateTime(\DateTime $dateTime): Date |
|
| 16 | { |
|
| 17 | return new self($dateTime->format('Y-m-d')); |
|
| 18 | } |
|
| 19 | } |
|
| 20 | ||
| @@ 7-19 (lines=13) @@ | ||
| 4 | ||
| 5 | namespace Linio\Type; |
|
| 6 | ||
| 7 | class Time extends \DateTime |
|
| 8 | { |
|
| 9 | public function __construct(string $time = 'now', \DateTimeZone $timezone = null) |
|
| 10 | { |
|
| 11 | parent::__construct($time, $timezone); |
|
| 12 | $this->setDate(1970, 1, 1); |
|
| 13 | } |
|
| 14 | ||
| 15 | public static function createFromDateTime(\DateTime $dateTime): Time |
|
| 16 | { |
|
| 17 | return new self($dateTime->format('H:i:s')); |
|
| 18 | } |
|
| 19 | } |
|
| 20 | ||