@@ 55-61 (lines=7) @@ | ||
52 | * |
|
53 | * @since 2.0.0 |
|
54 | */ |
|
55 | public function startOfWeek(\DateTime $datetime) |
|
56 | { |
|
57 | $diffInDays = intval($datetime->format('N')) - 1; |
|
58 | $intervalSpec = sprintf('P%sD', $diffInDays); |
|
59 | ||
60 | $datetime->sub(new \DateInterval($intervalSpec)); |
|
61 | } |
|
62 | ||
63 | /** |
|
64 | * Sets time for the end of a week. |
|
@@ 72-78 (lines=7) @@ | ||
69 | * |
|
70 | * @since 2.0.0 |
|
71 | */ |
|
72 | public function endOfWeek(\DateTime $datetime) |
|
73 | { |
|
74 | $diffInDays = 7 - intval($datetime->format('N')); |
|
75 | $intervalSpec = sprintf('P%sD', $diffInDays); |
|
76 | ||
77 | $datetime->add(new \DateInterval($intervalSpec)); |
|
78 | } |
|
79 | ||
80 | /** |
|
81 | * Sets time for the start of a month. |