Skip to content

Commit 806afdd

Browse files
committed
wip
1 parent 99cf0a4 commit 806afdd

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/Serializer/DateTimeUtcNormalizer.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ public function normalize(mixed $data, ?string $format = null, array $context =
3838
{
3939
assert($data instanceof \DateTimeInterface);
4040

41-
$utc = \DateTimeImmutable::createFromFormat('U.u', $data->format('U.u'), self::utc());
42-
if ($utc === false) {
43-
throw new \RuntimeException('Failed to normalize DateTimeInterface value.');
44-
}
41+
$utc = \DateTimeImmutable::createFromInterface($data)->setTimezone(self::utc());
4542

4643
return $utc->format(self::FORMAT_MILLISECONDS);
4744
}
@@ -68,7 +65,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
6865
return $dt;
6966
}
7067

71-
throw new \RuntimeException('Unsupported DateTime implementation.');
68+
throw new \RuntimeException('Unsupported DateTimeInterface implementation.');
7269
}
7370
}
7471

0 commit comments

Comments
 (0)