Skip to content

Commit 78410ca

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Messenger] Fix dealing with unexpected payload in Redis transport [Filesystem] Update some PHPDoc of the Path class [VarDumper] Fix dumping mysqli_driver instances Fix missing ReturnTypeWillChange attributes [Cache] Add missing log when saving namespace [HttpKernel] Reset services between requests performed by KernelBrowser [HttpKernel] Remove unused argument in ArgumentMetadataFactory [Stopwatch] Fix test expectation [SecurityBundle] fix autoconfiguring Monolog's ProcessorInterface KernelTestCase resets internal state on tearDown [Security/Http] Fix getting password-upgrader when user-loader is a closure [HttpKernel] Fix extracting controller name from closures [Intl] fix wrong offset timezone PHP 8.1 Fix type binding Remove duplicated test [Dotenv] Fix reading config for symfony/runtime when running dump command [Serializer] Remove unnecessary break [Runtime] Fix dotenv_overload with commands Make document type nodes ignorable Initialize Symfony\Component\Security\Core\Exception\AccountStatusException:: property
2 parents eeddf6c + 90a4e66 commit 78410ca

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Tests/TimezonesTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,4 +663,10 @@ public function provideCountries(): iterable
663663
return [$country];
664664
}, Countries::getCountryCodes());
665665
}
666+
667+
public function testGetRawOffsetChangeTimeCountry()
668+
{
669+
$this->assertSame(7200, Timezones::getRawOffset('Europe/Paris', (new \DateTime('2022-07-16 00:00:00+00:00'))->getTimestamp()));
670+
$this->assertSame(3600, Timezones::getRawOffset('Europe/Paris', (new \DateTime('2022-02-16 00:00:00+00:00'))->getTimestamp()));
671+
}
666672
}

Timezones.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,9 @@ public static function getNames(string $displayLocale = null): array
6868
*/
6969
public static function getRawOffset(string $timezone, int $timestamp = null): int
7070
{
71-
if (null === $timestamp) {
72-
$timestamp = time();
73-
}
74-
75-
$transitions = (new \DateTimeZone($timezone))->getTransitions($timestamp, $timestamp);
76-
77-
if (!isset($transitions[0]['offset'])) {
78-
throw new RuntimeException('No timezone transitions available.');
79-
}
71+
$dateTimeImmutable = new \DateTimeImmutable(date('Y-m-d H:i:s', $timestamp ?? time()), new \DateTimeZone($timezone));
8072

81-
return $transitions[0]['offset'];
73+
return $dateTimeImmutable->getOffset();
8274
}
8375

8476
public static function getGmtOffset(string $timezone, int $timestamp = null, string $displayLocale = null): string

0 commit comments

Comments
 (0)