8000 [RateLimiter] Fix DateInterval normalization · symfony/symfony@b137b90 · GitHub
[go: up one dir, main page]

Skip to content

Commit b137b90

Browse files
committed
[RateLimiter] Fix DateInterval normalization
1 parent 97aedb3 commit b137b90

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Symfony/Component/RateLimiter/RateLimiterFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ protected static function configureOptions(OptionsResolver $options): void
6969
{
7070
$intervalNormalizer = static function (Options $options, string $interval): \DateInterval {
7171
try {
72-
return (new \DateTimeImmutable())->diff(new \DateTimeImmutable('+'.$interval));
72+
// Force UTC timezone, because we don't want to deal with quirks happening when modifying dates in case
73+
// there is a default timezone with DST. Read more here https://github.com/symfony/symfony/pull/58757
74+
$now = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
75+
76+
return $now->diff($now->modify('+'.$interval));
7377
} catch (\Exception $e) {
7478
if (!preg_match('/Failed to parse time string \(\+([^)]+)\)/', $e->getMessage(), $m)) {
7579
throw $e;

0 commit comments

Comments
 (0)
0