Skip to content

Commit

Permalink
Fixed #134, no transitions now immediately returns null
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmantank committed Jan 18, 2022
1 parent 63f2a76 commit be85b3f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,16 @@
# Change Log

## [3.3.1] - 2022-01-18

### Added
- N/A

### Changed
- N/A

### Fixed
- Fixed issue when timezones had no transition, which can occur over very short timespans (#134)

## [3.3.0] - 2022-01-13

### Added
Expand Down
3 changes: 3 additions & 0 deletions src/Cron/HoursField.php
Expand Up @@ -92,6 +92,9 @@ public function getPastTransition(DateTimeInterface $date): ?array
$dtLimitStart->getTimestamp(),
$dtLimitEnd->getTimestamp()
);
if ($this->transitions === false) {
return null;
}
$this->transitionsStart = $dtLimitStart->getTimestamp();
$this->transitionsEnd = $dtLimitEnd->getTimestamp();
}
Expand Down
7 changes: 7 additions & 0 deletions tests/Cron/CronExpressionTest.php
Expand Up @@ -806,4 +806,11 @@ public function testItWillFailToUnregisterADefaultExpression(): void

CronExpression::unregisterAlias('@daily');
}

public function testIssue134ForeachInvalidArgumentOnHours()
{
$cron = new CronExpression('0 0 1 1 *');
$prev = $cron->getPreviousRunDate(new \DateTimeImmutable('2021-09-07T09:36:00Z'));
$this->assertEquals(new \DateTime('2021-01-01 00:00:00'), $prev);
}
}

0 comments on commit be85b3f

Please sign in to comment.