8000 [Form] fix support for years in on x86 arch · symfony/symfony@b0588de · GitHub
[go: up one dir, main page]

Skip to content

Commit b0588de

Browse files
[Form] fix support for years in on x86 arch
1 parent 0b81b38 commit b0588de

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

src/Symfony/Component/Form/Extension/Core/Type/DateType.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,7 @@ private function listYears(array $years)
375375
$result = [];
376376

377377
foreach ($years as $year) {
378-
if (false !== $y = gmmktime(0, 0, 0, 6, 15, $year)) {
379-
$result[$y] = $year;
380-
}
378+
$result[\PHP_INT_SIZE === 4 ? \DateTime::createFromFormat('Y e', $year.' UTC')->format('U') : gmmktime(0, 0, 0, 6, 15, $year)] = $year;
381379
}
382380

383381
return $result;

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,10 +929,6 @@ public function testDayErrorsBubbleUp($widget)
929929

930930
public function testYearsFor32BitsMachines()
931931
{
932-
if (4 !== \PHP_INT_SIZE) {
933-
$this->markTestSkipped('PHP 32 bit is required.');
934-
}
935-
936932
$view = $this->factory->create(static::TESTED_TYPE, null, [
937933
'years' => range(1900, 2040),
938934
])

src/Symfony/Component/Yaml/Inline.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -673,17 +673,16 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
673673
case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
674674
return (float) str_replace('_', '', $scalar);
675675
case Parser::preg_match(self::getTimestampRegex(), $scalar):
676+
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
677+
$time = new \DateTime($scalar, new \DateTimeZone('UTC'));
678+
676679
if (Yaml::PARSE_DATETIME & $flags) {
677-
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
678-
return new \DateTime($scalar, new \DateTimeZone('UTC'));
680+
return $time;
679681
}
680682

681-
$timeZone = date_default_timezone_get();
682-
date_default_timezone_set('UTC');
683-
$time = strtotime($scalar);
684-
date_default_timezone_set($timeZone);
683+
$scalar = $time->getTimestamp();
685684

686-
return $time;
685+
return false !== $scalar ? $scalar : $time->format('U');
687686
}
688687
}
689688

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public function getTestsForParse()
326326
['2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)],
327327
['2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)],
328328
['1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)],
329-
['1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)],
329+
['1730-10-30T02:59:43Z', \PHP_INT_SIZE === 4 ? '-7547547617' : gmmktime(2, 59, 43, 10, 30, 1730)],
330330

331331
['"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''],
332332
["'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''],
@@ -397,7 +397,7 @@ public function getTestsForParseWithMapObjects()
397397
['2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)],
398398
['2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)],
399399
['1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)],
400-
['1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)],
400+
['1730-10-30T02:59:43Z', \PHP_INT_SIZE === 4 ? '-7547547617' : gmmktime(2, 59, 43, 10, 30, 1730)],
401401

402402
['"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''],
403403
["'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''],

0 commit comments

Comments
 (0)
0