Skip to content

Commit f8f0205

Browse files
[Form] fix support for years outside of the 32b range on x86 arch
1 parent cad7609 commit f8f0205

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

Extension/Core/Type/DateType.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,7 @@ private function listYears(array $years)
381381
$result = [];
382382

383383
foreach ($years as $year) {
384-
if (false !== $y = gmmktime(0, 0, 0, 6, 15, $year)) {
385-
$result[$y] = $year;
386-
}
384+
$result[\PHP_INT_SIZE === 4 ? \DateTime::createFromFormat('Y e', $year.' UTC')->format('U') : gmmktime(0, 0, 0, 6, 15, $year)] = $year;
387385
}
388386

389387
return $result;

Tests/Extension/Core/Type/DateTypeTest.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -927,19 +927,15 @@ public function testDayErrorsBubbleUp($widget)
927927
$this->assertSame([$error], iterator_to_array($form->getErrors()));
928928
}
929929

930-
public function testYearsFor32BitsMachines()
930+
public function testYears()
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, [
937-
'years' => range(1900, 2040),
933+
'years' => [1900, 2000, 2040],
938934
])
939935
->createView();
940936

941937
$listChoices = [];
942-
foreach (range(1902, 2037) as $y) {
938+
foreach ([1900, 2000, 2040] as $y) {
943939
$listChoices[] = new ChoiceView($y, $y, $y);
944940
}
945941

0 commit comments

Comments
 (0)