diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php index 71b95c8b9e7e0..83d840020664e 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php @@ -35,10 +35,18 @@ public function format(\DateTime $dateTime, int $length): string return $this->padLeft($quarter, $length); case 3: return 'Q'.$quarter; - default: + case 4: $map = [1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter']; return $map[$quarter]; + default: + if (\defined('INTL_ICU_VERSION') && version_compare(\INTL_ICU_VERSION, '70.1', '<')) { + $map = [1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter']; + + return $map[$quarter]; + } else { + return $quarter; + } } } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 6c1dc2f7c685e..c6328ab20e24e 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -96,6 +96,12 @@ public function formatProvider() $dateTime = new \DateTime('@0'); $dateTimeImmutable = new \DateTimeImmutable('@0'); + /* https://unicode-org.atlassian.net/browse/ICU-21647 */ + $expectedQuarterX5 = '1'; + if (\defined('INTL_ICU_VERSION') && version_compare(\INTL_ICU_VERSION, '70.1', '<')) { + $expectedQuarterX5 = '1st quarter'; + } + $formatData = [ /* general */ ['y-M-d', 0, '1970-1-1'], @@ -144,13 +150,13 @@ public function formatProvider() ['QQ', 0, '01'], ['QQQ', 0, 'Q1'], ['QQQQ', 0, '1st quarter'], - ['QQQQQ', 0, '1st quarter'], + ['QQQQQ', 0, $expectedQuarterX5], ['q', 0, '1'], ['qq', 0, '01'], ['qqq', 0, 'Q1'], ['qqqq', 0, '1st quarter'], - ['qqqqq', 0, '1st quarter'], + ['qqqqq', 0, $expectedQuarterX5], // 4 months ['Q', 7776000, '2'], @@ -363,6 +369,10 @@ public function formatWithTimezoneProvider() */ public function testFormatTimezone($pattern, $timezone, $expected) { + if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && str_contains($timezone, 'GMT')) { + $this->markTestSkipped('Broken version of PHP'); + } + $formatter = $this->getDefaultDateFormatter($pattern); $formatter->setTimeZone(new \DateTimeZone($timezone)); @@ -421,6 +431,10 @@ public function formatTimezoneProvider() public function testFormatWithGmtTimezone() { + if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) { + $this->markTestSkipped('Broken version of PHP'); + } + $formatter = $this->getDefaultDateFormatter('zzzz'); $formatter->setTimeZone('GMT+03:00'); @@ -430,6 +444,10 @@ public function testFormatWithGmtTimezone() public function testFormatWithGmtTimeZoneAndMinutesOffset() { + if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) { + $this->markTestSkipped('Broken version of PHP'); + } + $formatter = $this->getDefaultDateFormatter('zzzz'); $formatter->setTimeZone('GMT+00:30'); @@ -794,6 +812,10 @@ public function parseSecondProvider() public function parseTimezoneProvider() { + if (80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) { + return [['y-M-d HH:mm:ss', '1970-1-1 00:00:00', 0]]; + } + return [ ['y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-03:00', 10800], ['y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-04:00', 14400], @@ -912,6 +934,10 @@ public function testSetPattern() */ public function testSetTimeZoneId($timeZoneId, $expectedTimeZoneId) { + if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && str_contains($timeZoneId ?? '', 'GMT')) { + $this->markTestSkipped('Broken version of PHP'); + } + $formatter = $this->getDefaultDateFormatter(); $formatter->setTimeZone($timeZoneId); diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 765ac9cf9b8a0..9113403fa1128 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -186,6 +186,10 @@ public function testParseThreeDigitsYears() protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null) { + if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && \is_string($timezone) && str_contains($timezone, 'GMT')) { + $this->markTestSkipped('Broken version of PHP'); + } + return new class($locale, $datetype, $timetype, $timezone, $calendar, $pattern) extends IntlDateFormatter { }; } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php index 9ce1a6227a979..ff8e9971ce5de 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php @@ -35,6 +35,10 @@ protected function setUp(): void */ public function testFormatTimezone($pattern, $timezone, $expected) { + if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && str_contains($timezone, 'GMT')) { + $this->markTestSkipped('Broken version of PHP'); + } + IntlTestHelper::requireFullIntl($this, '59.1'); parent::testFormatTimezone($pattern, $timezone, $expected); @@ -59,6 +63,10 @@ public function testDateAndTimeType($timestamp, $datetype, $timetype, $expected) protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null) { + if ((80114 === \PHP_VERSION_ID || 80201 === \PHP_VERSION_ID) && \is_string($timezone) && str_contains($timezone, 'GMT')) { + $this->markTestSkipped('Broken version of PHP'); + } + IntlTestHelper::requireFullIntl($this, '55.1'); if (!$formatter = new \IntlDateFormatter($locale, $datetype ?? IntlDateFormatter::FULL, $timetype ?? IntlDateFormatter::FULL, $timezone, $calendar, $pattern)) {