| @@ 15-46 (lines=32) @@ | ||
| 12 | ||
| 13 | use GpsLab\Component\Interval\BaseIntervalPoint; |
|
| 14 | ||
| 15 | class DateIntervalPoint extends BaseIntervalPoint |
|
| 16 | { |
|
| 17 | /** |
|
| 18 | * @var \DateTime |
|
| 19 | */ |
|
| 20 | private $date; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @param \DateTime $date |
|
| 24 | */ |
|
| 25 | public function __construct(\DateTime $date) |
|
| 26 | { |
|
| 27 | $this->date = clone $date; |
|
| 28 | $this->date->setTime(0, 0, 0); |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @return \DateTime |
|
| 33 | */ |
|
| 34 | public function value() |
|
| 35 | { |
|
| 36 | return clone $this->date; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @return string |
|
| 41 | */ |
|
| 42 | public function __toString() |
|
| 43 | { |
|
| 44 | return $this->value()->format('Y-m-d'); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 15-46 (lines=32) @@ | ||
| 12 | ||
| 13 | use GpsLab\Component\Interval\BaseIntervalPoint; |
|
| 14 | ||
| 15 | class TimeIntervalPoint extends BaseIntervalPoint |
|
| 16 | { |
|
| 17 | /** |
|
| 18 | * @var \DateTime |
|
| 19 | */ |
|
| 20 | private $date; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @param \DateTime $date |
|
| 24 | */ |
|
| 25 | public function __construct(\DateTime $date) |
|
| 26 | { |
|
| 27 | $this->date = clone $date; |
|
| 28 | $this->date->setDate(1, 1, 1); |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @return \DateTime |
|
| 33 | */ |
|
| 34 | public function value() |
|
| 35 | { |
|
| 36 | return clone $this->date; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @return string |
|
| 41 | */ |
|
| 42 | public function __toString() |
|
| 43 | { |
|
| 44 | return $this->value()->format('H:i:s'); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||