Skip to content

Commit

Permalink
Fix DateType for 32bits computers.
Browse files Browse the repository at this point in the history
  • Loading branch information
WedgeSama authored and fabpot committed Nov 28, 2013
1 parent 3aa4e14 commit 2f9bb75
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Symfony/Component/Form/Extension/Core/Type/DateType.php
Expand Up @@ -300,7 +300,9 @@ private function listYears(array $years)
$result = array();

foreach ($years as $year) {
$result[$year] = gmmktime(0, 0, 0, 6, 15, $year);
if (false !== $y = gmmktime(0, 0, 0, 6, 15, $year)) {
$result[$year] = $y;
}
}

return $result;
Expand Down
Expand Up @@ -774,4 +774,25 @@ public function testDayErrorsBubbleUp($widget)
$this->assertSame(array(), $form['day']->getErrors());
$this->assertSame(array($error), $form->getErrors());
}

public function testYearsFor32BitsMachines()
{
if (4 !== PHP_INT_SIZE) {
$this->markTestSkipped(
'PHP must be compiled in 32 bit mode to run this test');
}

$form = $this->factory->create('date', null, array(
'years' => range(1900, 2040),
));

$view = $form->createView();

$listChoices = array();
foreach(range(1902, 2037) as $y) {
$listChoices[] = new ChoiceView($y, $y, $y);
}

$this->assertEquals($listChoices, $view['year']->vars['choices']);
}
}

0 comments on commit 2f9bb75

Please sign in to comment.