update tests
This commit is contained in:
@@ -15,17 +15,17 @@ class ParentAttendanceReportCalendarService
|
||||
*/
|
||||
public function computeSundays(int $weeksBefore = 4, int $weeksAfter = 26): array
|
||||
{
|
||||
$today = new \DateTime('today');
|
||||
$today = now()->startOfDay();
|
||||
$dow = (int) $today->format('w');
|
||||
|
||||
$thisSunday = clone $today;
|
||||
$thisSunday = $today->copy();
|
||||
if ($dow !== 0) {
|
||||
$thisSunday->modify('last sunday');
|
||||
}
|
||||
|
||||
$default = clone $today;
|
||||
$default = $today->copy();
|
||||
if ($dow !== 0) {
|
||||
$default->modify('next sunday');
|
||||
$default = $default->copy()->modify('next sunday');
|
||||
}
|
||||
|
||||
$schoolYear = (string) ($this->configService->context()['school_year'] ?? '');
|
||||
@@ -33,13 +33,13 @@ class ParentAttendanceReportCalendarService
|
||||
|
||||
$dates = [];
|
||||
for ($i = $weeksBefore; $i >= 1; $i--) {
|
||||
$dates[] = (clone $thisSunday)->modify('-' . $i . ' week');
|
||||
$dates[] = $thisSunday->copy()->modify('-' . $i . ' week');
|
||||
}
|
||||
|
||||
$cursor = clone $thisSunday;
|
||||
$cursor = $thisSunday->copy();
|
||||
while ($cursor <= $cap) {
|
||||
$dates[] = clone $cursor;
|
||||
$cursor->modify('+1 week');
|
||||
$dates[] = $cursor->copy();
|
||||
$cursor = $cursor->copy()->modify('+1 week');
|
||||
}
|
||||
|
||||
$rangeStart = reset($dates);
|
||||
@@ -108,7 +108,7 @@ class ParentAttendanceReportCalendarService
|
||||
|
||||
public function firstSundayOfJune(string $schoolYear): \DateTime
|
||||
{
|
||||
$today = new \DateTime('today');
|
||||
$today = now()->startOfDay();
|
||||
$endYear = null;
|
||||
if (preg_match('/^(\\d{4})\\D(\\d{4})$/', $schoolYear, $m)) {
|
||||
$endYear = (int) $m[2];
|
||||
@@ -118,10 +118,11 @@ class ParentAttendanceReportCalendarService
|
||||
$endYear = ((int) $today->format('n') > 6) ? ($y + 1) : $y;
|
||||
}
|
||||
|
||||
$juneFirst = new \DateTime(sprintf('%04d-06-01', $endYear));
|
||||
$juneFirst = now()->parse(sprintf('%04d-06-01', $endYear))->startOfDay();
|
||||
if ((int) $juneFirst->format('w') !== 0) {
|
||||
$juneFirst->modify('next sunday');
|
||||
$juneFirst = $juneFirst->copy()->modify('next sunday');
|
||||
}
|
||||
|
||||
return $juneFirst;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user