Skip to content

Commit

Permalink
Fix for DOW DST changes, and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmantank committed Jan 13, 2022
1 parent 9c6ee74 commit 9545dea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## [3.2.4] - 2022-01-12

### Added
- N/A

### Changed
- Changed how Day of Week increment/decrement to help with DST changes (#131)

### Fixed
- N/A

## [3.2.3] - 2022-01-05

### Added
Expand Down
4 changes: 2 additions & 2 deletions src/Cron/DayOfWeekField.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ public function isSatisfiedBy(DateTimeInterface $date, $value, bool $invert): bo
public function increment(DateTimeInterface &$date, $invert = false, $parts = null): FieldInterface
{
if (! $invert) {
$date = $this->timezoneSafeModify($date, '+1 day');
$date = $date->add(new \DateInterval('P1D'));
$date = $date->setTime(0, 0);
} else {
$date = $this->timezoneSafeModify($date, '-1 day');
$date = $date->sub(new \DateInterval('P1D'));
$date = $date->setTime(23, 59);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Cron/CronExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,12 @@ public function testBerlinShouldAdvanceProperlyOverDST()
public function testIssue131()
{
$e = new CronExpression('* * * * 2');
$expected = new \DateTime('2020-10-27 00:00:00');
$next = $e->getNextRunDate(new DateTime('2020-10-23 15:31:45'));
$expected = new \DateTime('2020-10-27 00:00:00', new \DateTimeZone('Europe/Berlin'));
$next = $e->getNextRunDate(new DateTime('2020-10-23 15:31:45', new \DateTimeZone('Europe/Berlin')));
$this->assertEquals($expected, $next);

$expected = new \DateTime('2020-10-20 23:59:00');
$prev = $e->getPreviousRunDate(new DateTime('2020-10-23 15:31:45'));
$expected = new \DateTime('2020-10-20 23:59:00', new \DateTimeZone('Europe/Berlin'));
$prev = $e->getPreviousRunDate(new DateTime('2020-10-23 15:31:45', new \DateTimeZone('Europe/Berlin')));
$this->assertEquals($expected, $prev);

$e = new CronExpression('15 1 1 9,11 *');
Expand Down

0 comments on commit 9545dea

Please sign in to comment.