1 | <?php |
||
15 | class WeekIntervalPoint extends BaseIntervalPoint |
||
16 | { |
||
17 | /** |
||
18 | * @var \DateTime |
||
19 | */ |
||
20 | private $week; |
||
21 | |||
22 | /** |
||
23 | * @param \DateTime $date |
||
24 | */ |
||
25 | 4 | public function __construct(\DateTime $date) |
|
29 | |||
30 | /** |
||
31 | * Bugfix for get monday of this week. |
||
32 | * |
||
33 | * @see https://bugs.php.net/bug.php?id=63740 |
||
34 | * |
||
35 | * @param \DateTime $date |
||
36 | * |
||
37 | * @return \DateTime |
||
38 | */ |
||
39 | 4 | private function getMondayThisWeek(\DateTime $date) |
|
40 | { |
||
41 | 4 | $monday = clone $date; |
|
42 | |||
43 | 4 | if ($monday->format('N') != 1) { |
|
44 | 2 | $monday->modify('Monday this week'); |
|
45 | |||
46 | 2 | if ($date->format('Y W') != $monday->format('Y W')) { |
|
47 | $monday->modify('-7 day'); |
||
48 | } |
||
49 | 2 | } |
|
50 | |||
51 | 4 | return $monday; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return \DateTime |
||
56 | */ |
||
57 | 4 | public function value() |
|
61 | |||
62 | /** |
||
63 | * @return string |
||
64 | */ |
||
65 | 1 | public function __toString() |
|
69 | } |
||
70 |