fix first week in year shows wrong year (#2239)

This commit is contained in:
Kevin Papst
2021-01-08 15:12:42 +01:00
committed by GitHub
parent 244169d6d5
commit 1aae4f4d0f
2 changed files with 5 additions and 5 deletions

View File

@@ -51,7 +51,7 @@ class DateTimeFactory
$date = $this->createDateTime('now');
}
return $this->createWeekDateTime($date->format('Y'), $date->format('W'), 1, 0, 0, 0);
return $this->createWeekDateTime($date->format('o'), $date->format('W'), 1, 0, 0, 0);
}
public function getEndOfWeek(?DateTime $date = null): DateTime
@@ -60,7 +60,7 @@ class DateTimeFactory
$date = $this->createDateTime('now');
}
return $this->createWeekDateTime($date->format('Y'), $date->format('W'), 7, 23, 59, 59);
return $this->createWeekDateTime($date->format('o'), $date->format('W'), 7, 23, 59, 59);
}
public function getEndOfMonth(): DateTime

View File

@@ -27,7 +27,7 @@ final class PaginatedWorkingTimeChart extends SimpleWidget implements UserWidget
$this->setTitle('stats.yourWorkingHours');
$this->setOptions([
'year' => (new DateTime('now'))->format('Y'),
'year' => (new DateTime('now'))->format('o'),
'week' => (new DateTime('now'))->format('W'),
'type' => 'bar',
]);
@@ -38,7 +38,7 @@ final class PaginatedWorkingTimeChart extends SimpleWidget implements UserWidget
$this->setOption('user', $user);
$now = new DateTime('now', new \DateTimeZone($user->getTimezone()));
$this->setOptions([
'year' => $now->format('Y'),
'year' => $now->format('o'),
'week' => $now->format('W'),
]);
}
@@ -90,7 +90,7 @@ final class PaginatedWorkingTimeChart extends SimpleWidget implements UserWidget
$thisMonth = clone $weekBegin;
if ((int) $options['week'] === 1) {
$thisMonth = (new DateTime())->setISODate($options['year'], $options['week'], 7)->setTime(0, 0, 0);
$thisMonth = (new DateTime('now', $timezone))->setISODate($options['year'], $options['week'], 7)->setTime(0, 0, 0);
}
return [