Skip to content

Commit

Permalink
self-assert the timezone; the assert-library no longer does
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jul 24, 2024
1 parent 49d0751 commit 8ec328e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ public static function addStrings(
*/
public static function xsDateTimeToTimestamp(string $time): int
{
Assert::validDateTimeZulu($time);
Assert::validDateTime($time);
Assert::same($dateTime->getTimeZone()->getName(), 'Z');

Check failure on line 156 in src/Utils.php

View workflow job for this annotation

GitHub Actions / Quality control

Undefined variable: $dateTime

$dateTime1 = DateTimeImmutable::createFromFormat(DateTimeInterface::ISO8601, $time);
$dateTime2 = DateTimeImmutable::createFromFormat(DateTimeInterface::RFC3339_EXTENDED, $time);

$dateTime = $dateTime1 ?: $dateTime2;
Assert::isInstanceOf($dateTime, DateTimeImmutable::class);

return $dateTime->getTimestamp();
}
}

0 comments on commit 8ec328e

Please sign in to comment.