Skip to content

Commit 18663f4

Browse files
committed
TimeGrid\Util: Throw in diffHours if $to is smaller than $from
1 parent 0cc55f9 commit 18663f4

File tree

1 file changed

+4
-0
lines changed
  • library/Notifications/Widget/TimeGrid

1 file changed

+4
-0
lines changed

library/Notifications/Widget/TimeGrid/Util.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Icinga\Module\Notifications\Widget\TimeGrid;
66

77
use DateTime;
8+
use InvalidArgumentException;
89

910
final class Util
1011
{
@@ -14,6 +15,9 @@ final class Util
1415
public static function diffHours(DateTime $from, DateTime $to)
1516
{
1617
$diff = $from->diff($to);
18+
if ($diff->invert) {
19+
throw new InvalidArgumentException('The end date must be after the start date');
20+
}
1721

1822
$hours = 0;
1923
if ($diff->h > 0) {

0 commit comments

Comments
 (0)