@@ 100-115 (lines=16) @@ | ||
97 | * @return string |
|
98 | * @throws \Exception |
|
99 | */ |
|
100 | public function startOfWeek($date = null) |
|
101 | { |
|
102 | $now = clone $this->dateTimeProvider->get(); |
|
103 | ||
104 | if ($date) { |
|
105 | $now = $this->modifyDate($now, $date); |
|
106 | } |
|
107 | ||
108 | $year = $now->format('o'); // o = ISO-8601 year number |
|
109 | $week = $now->format('W'); // W = ISO-8601 week number of year, weeks starting on Monday |
|
110 | ||
111 | $startOfWeek = $now->setISODate($year, $week); |
|
112 | $startOfWeek->setTime(0, 0, 0); |
|
113 | ||
114 | return $startOfWeek->format(\DateTime::ISO8601); |
|
115 | } |
|
116 | ||
117 | /** |
|
118 | * Gets the first day of the month for the specified date with the hour 00:00:00 |
|
@@ 125-140 (lines=16) @@ | ||
122 | * @return string |
|
123 | * @throws \Exception |
|
124 | */ |
|
125 | public function startOfMonth($date = null) |
|
126 | { |
|
127 | $now = clone $this->dateTimeProvider->get(); |
|
128 | ||
129 | if ($date) { |
|
130 | $now = $this->modifyDate($now, $date); |
|
131 | } |
|
132 | ||
133 | $year = $now->format('Y'); |
|
134 | $month = $now->format('m'); |
|
135 | ||
136 | $startOfMonth = $now->setDate($year, $month, 1); |
|
137 | $startOfMonth->setTime(0, 0, 0); |
|
138 | ||
139 | return $startOfMonth->format(\DateTime::ISO8601); |
|
140 | } |
|
141 | ||
142 | /** |
|
143 | * Gets the first day of the year for the specified date with the hour 00:00:00 |