Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] Remove timezone options from DateType and TimeType #12380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Drop support for model_timezone and view_timezone options in DateType.
  • Loading branch information
jakzal committed Nov 2, 2014
commit 7ef6bb69c09942b3210e33fd7c938f40eca92057
12 changes: 6 additions & 6 deletions 12 src/Symfony/Component/Form/Extension/Core/Type/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)

if ('single_text' === $options['widget']) {
$builder->addViewTransformer(new DateTimeToLocalizedStringTransformer(
$options['model_timezone'],
$options['view_timezone'],
'UTC',
'UTC',
$dateFormat,
$timeFormat,
$calendar,
Expand Down Expand Up @@ -105,23 +105,23 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('month', $options['widget'], $monthOptions)
->add('day', $options['widget'], $dayOptions)
->addViewTransformer(new DateTimeToArrayTransformer(
$options['model_timezone'], $options['view_timezone'], array('year', 'month', 'day')
'UTC', 'UTC', array('year', 'month', 'day')
))
->setAttribute('formatter', $formatter)
;
}

if ('string' === $options['input']) {
$builder->addModelTransformer(new ReversedTransformer(
new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'], 'Y-m-d')
new DateTimeToStringTransformer('UTC', 'UTC', 'Y-m-d')
));
} elseif ('timestamp' === $options['input']) {
$builder->addModelTransformer(new ReversedTransformer(
new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone'])
new DateTimeToTimestampTransformer('UTC', 'UTC')
));
} elseif ('array' === $options['input']) {
$builder->addModelTransformer(new ReversedTransformer(
new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], array('year', 'month', 'day'))
new DateTimeToArrayTransformer('UTC', 'UTC', array('year', 'month', 'day'))
));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

class DateTypeTest extends TypeTestCase
{
private $defaultTimezone;

protected function setUp()
{
parent::setUp();
Expand All @@ -25,6 +27,13 @@ protected function setUp()
IntlTestHelper::requireFullIntl($this);

\Locale::setDefault('de_AT');

$this->defaultTimezone = date_default_timezone_get();
}

protected function tearDown()
{
date_default_timezone_set($this->defaultTimezone);
}

/**
Expand All @@ -50,8 +59,6 @@ public function testInvalidInputOption()
public function testSubmitFromSingleTextDateTimeWithDefaultFormat()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'datetime',
));
Expand All @@ -66,8 +73,6 @@ public function testSubmitFromSingleTextDateTime()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'datetime',
));
Expand All @@ -82,8 +87,6 @@ public function testSubmitFromSingleTextString()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'string',
));
Expand All @@ -98,8 +101,6 @@ public function testSubmitFromSingleTextTimestamp()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'timestamp',
));
Expand All @@ -116,8 +117,6 @@ public function testSubmitFromSingleTextRaw()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'array',
));
Expand All @@ -137,8 +136,6 @@ public function testSubmitFromSingleTextRaw()
public function testSubmitFromText()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'text',
));

Expand All @@ -159,8 +156,6 @@ public function testSubmitFromText()
public function testSubmitFromChoice()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));

Expand All @@ -181,8 +176,6 @@ public function testSubmitFromChoice()
public function testSubmitFromChoiceEmpty()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
'required' => false,
));
Expand All @@ -202,8 +195,6 @@ public function testSubmitFromChoiceEmpty()
public function testSubmitFromInputDateTimeDifferentPattern()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'datetime',
Expand All @@ -218,8 +209,6 @@ public function testSubmitFromInputDateTimeDifferentPattern()
public function testSubmitFromInputStringDifferentPattern()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'string',
Expand All @@ -234,8 +223,6 @@ public function testSubmitFromInputStringDifferentPattern()
public function testSubmitFromInputTimestampDifferentPattern()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'timestamp',
Expand All @@ -252,8 +239,6 @@ public function testSubmitFromInputTimestampDifferentPattern()
public function testSubmitFromInputRawDifferentPattern()
{
$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'array',
Expand Down Expand Up @@ -370,27 +355,12 @@ public function testThrowExceptionIfDaysIsInvalid()
));
}

public function testSetDataWithDifferentTimezones()
public function testSetDataWithDifferentTimezoneDateTime()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'America/New_York',
'view_timezone' => 'Pacific/Tahiti',
'input' => 'string',
'widget' => 'single_text',
));
date_default_timezone_set('Pacific/Tahiti');

$form->setData('2010-06-02');

$this->assertEquals('01.06.2010', $form->getViewData());
}

public function testSetDataWithDifferentTimezonesDateTime()
{
$form = $this->factory->create('date', null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'America/New_York',
'view_timezone' => 'Pacific/Tahiti',
'input' => 'datetime',
'widget' => 'single_text',
));
Expand All @@ -400,7 +370,7 @@ public function testSetDataWithDifferentTimezonesDateTime()
$form->setData($dateTime);

$this->assertDateTimeEquals($dateTime, $form->getData());
$this->assertEquals('01.06.2010', $form->getViewData());
$this->assertEquals('02.06.2010', $form->getViewData());
}

public function testYearsOption()
Expand Down Expand Up @@ -495,8 +465,6 @@ public function testIsPartiallyFilledReturnsFalseIfSingleText()
$this->markTestIncomplete('Needs to be reimplemented using validators');

$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
));

Expand All @@ -510,8 +478,6 @@ public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyEmpty()
$this->markTestIncomplete('Needs to be reimplemented using validators');

$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));

Expand All @@ -529,8 +495,6 @@ public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyFilled()
$this->markTestIncomplete('Needs to be reimplemented using validators');

$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));

Expand All @@ -548,8 +512,6 @@ public function testIsPartiallyFilledReturnsTrueIfChoiceAndDayEmpty()
$this->markTestIncomplete('Needs to be reimplemented using validators');

$form = $this->factory->create('date', null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.