Skip to content

Commit

Permalink
[#14] Fixed UnexpectedValueException - DateTime not parsable
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Lucich committed Nov 29, 2024
1 parent 21b2cfe commit dc4c4a4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Handlers/AbstractHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ public static function parseStandardDate(string $date)
$rules = [

// 2020-01-01T00:00:00.0Z
'/^(?<datetime>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(?<microseconds>\d+)(?<timezone>Z)$/' => 'Y-m-d\TH:i:s.vT',
'/^(?<datetime>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.(?<microseconds>\d+)(?<timezone>Z)$/' => 'Y-m-d\TH:i:s.uT',

// 2020-01-01T00:00:00Z
'/^(?<datetime>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?<timezone>Z)$/' => 'Y-m-d\TH:i:sT',
Expand Down Expand Up @@ -990,6 +990,8 @@ public static function parseStandardDate(string $date)
foreach( $rules as $regex => $dateTimeFormat ){
$matches = [];

preg_match($regex, $date, $matches);

if( preg_match($regex, $date, $matches) ){

if( !empty($matches['microseconds']) && PHP_VERSION_ID <= 80200 ){
Expand Down

0 comments on commit dc4c4a4

Please sign in to comment.