add back model_timezone and view_timezone options
This commit is contained in:
parent
fb23abe18d
commit
1c4a75a00a
@ -1,13 +1,20 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
2.6.2
|
||||||
|
-----
|
||||||
|
|
||||||
|
* Added back the `model_timezone` and `view_timezone` options for `TimeType`, `DateType`
|
||||||
|
and `BirthdayType`
|
||||||
|
|
||||||
2.6.0
|
2.6.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
* added "html5" option to Date, Time and DateTimeFormType to be able to
|
* added "html5" option to Date, Time and DateTimeFormType to be able to
|
||||||
enable/disable HTML5 input date when widget option is "single_text"
|
enable/disable HTML5 input date when widget option is "single_text"
|
||||||
* added "label_format" option with possible placeholders "%name%" and "%id%"
|
* added "label_format" option with possible placeholders "%name%" and "%id%"
|
||||||
* [BC BREAK] drop support for model_timezone and view_timezone options in TimeType, DateType and BirthdayType
|
* [BC BREAK] drop support for model_timezone and view_timezone options in TimeType, DateType and BirthdayType,
|
||||||
|
update to 2.6.2 to get back support for these options
|
||||||
|
|
||||||
2.5.0
|
2.5.0
|
||||||
------
|
------
|
||||||
|
@ -197,6 +197,8 @@ class TimeType extends AbstractType
|
|||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_minutes' => true,
|
'with_minutes' => true,
|
||||||
'with_seconds' => false,
|
'with_seconds' => false,
|
||||||
|
'model_timezone' => null,
|
||||||
|
'view_timezone' => null,
|
||||||
'empty_value' => $emptyValue, // deprecated
|
'empty_value' => $emptyValue, // deprecated
|
||||||
'placeholder' => $placeholder,
|
'placeholder' => $placeholder,
|
||||||
'html5' => true,
|
'html5' => true,
|
||||||
|
@ -60,6 +60,8 @@ class DateTypeTest extends TestCase
|
|||||||
public function testSubmitFromSingleTextDateTimeWithDefaultFormat()
|
public function testSubmitFromSingleTextDateTimeWithDefaultFormat()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
));
|
));
|
||||||
@ -74,6 +76,8 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
));
|
));
|
||||||
@ -88,6 +92,8 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
));
|
));
|
||||||
@ -102,6 +108,8 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'timestamp',
|
'input' => 'timestamp',
|
||||||
));
|
));
|
||||||
@ -118,6 +126,8 @@ class DateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
));
|
));
|
||||||
@ -137,6 +147,8 @@ class DateTypeTest extends TestCase
|
|||||||
public function testSubmitFromText()
|
public function testSubmitFromText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'text',
|
'widget' => 'text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -157,6 +169,8 @@ class DateTypeTest extends TestCase
|
|||||||
public function testSubmitFromChoice()
|
public function testSubmitFromChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -177,6 +191,8 @@ class DateTypeTest extends TestCase
|
|||||||
public function testSubmitFromChoiceEmpty()
|
public function testSubmitFromChoiceEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
@ -196,6 +212,8 @@ class DateTypeTest extends TestCase
|
|||||||
public function testSubmitFromInputDateTimeDifferentPattern()
|
public function testSubmitFromInputDateTimeDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
@ -210,6 +228,8 @@ class DateTypeTest extends TestCase
|
|||||||
public function testSubmitFromInputStringDifferentPattern()
|
public function testSubmitFromInputStringDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -224,6 +244,8 @@ class DateTypeTest extends TestCase
|
|||||||
public function testSubmitFromInputTimestampDifferentPattern()
|
public function testSubmitFromInputTimestampDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'timestamp',
|
'input' => 'timestamp',
|
||||||
@ -240,6 +262,8 @@ class DateTypeTest extends TestCase
|
|||||||
public function testSubmitFromInputRawDifferentPattern()
|
public function testSubmitFromInputRawDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
@ -358,10 +382,25 @@ class DateTypeTest extends TestCase
|
|||||||
|
|
||||||
public function testSetDataWithDifferentNegativeUTCTimezoneDateTime()
|
public function testSetDataWithDifferentNegativeUTCTimezoneDateTime()
|
||||||
{
|
{
|
||||||
date_default_timezone_set('Pacific/Tahiti');
|
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
'model_timezone' => 'America/New_York',
|
||||||
|
'view_timezone' => 'Pacific/Tahiti',
|
||||||
|
'input' => 'string',
|
||||||
|
'widget' => 'single_text',
|
||||||
|
));
|
||||||
|
|
||||||
|
$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',
|
'input' => 'datetime',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -371,7 +410,7 @@ class DateTypeTest extends TestCase
|
|||||||
$form->setData($dateTime);
|
$form->setData($dateTime);
|
||||||
|
|
||||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||||
$this->assertEquals('02.06.2010', $form->getViewData());
|
$this->assertEquals('01.06.2010', $form->getViewData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetDataWithDifferentPositiveUTCTimezoneDateTime()
|
public function testSetDataWithDifferentPositiveUTCTimezoneDateTime()
|
||||||
@ -520,6 +559,8 @@ class DateTypeTest extends TestCase
|
|||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -533,6 +574,8 @@ class DateTypeTest extends TestCase
|
|||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -550,6 +593,8 @@ class DateTypeTest extends TestCase
|
|||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -567,6 +612,8 @@ class DateTypeTest extends TestCase
|
|||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -18,25 +18,18 @@ use Symfony\Component\Intl\Util\IntlTestHelper;
|
|||||||
|
|
||||||
class TimeTypeTest extends TestCase
|
class TimeTypeTest extends TestCase
|
||||||
{
|
{
|
||||||
private $defaultTimezone;
|
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
IntlTestHelper::requireIntl($this);
|
IntlTestHelper::requireIntl($this);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->defaultTimezone = date_default_timezone_get();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown()
|
|
||||||
{
|
|
||||||
date_default_timezone_set($this->defaultTimezone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubmitDateTime()
|
public function testSubmitDateTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -56,6 +49,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitString()
|
public function testSubmitString()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -73,6 +68,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitTimestamp()
|
public function testSubmitTimestamp()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'timestamp',
|
'input' => 'timestamp',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -92,6 +89,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitArray()
|
public function testSubmitArray()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -109,6 +108,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitDatetimeSingleText()
|
public function testSubmitDatetimeSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -122,6 +123,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitDatetimeSingleTextWithoutMinutes()
|
public function testSubmitDatetimeSingleTextWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
@ -136,6 +139,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitArraySingleText()
|
public function testSubmitArraySingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -154,6 +159,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitArraySingleTextWithoutMinutes()
|
public function testSubmitArraySingleTextWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
@ -172,6 +179,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitArraySingleTextWithSeconds()
|
public function testSubmitArraySingleTextWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
@ -192,6 +201,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitStringSingleText()
|
public function testSubmitStringSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -205,6 +216,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSubmitStringSingleTextWithoutMinutes()
|
public function testSubmitStringSingleTextWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
@ -219,6 +232,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSetDataWithoutMinutes()
|
public function testSetDataWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
));
|
));
|
||||||
@ -231,6 +246,8 @@ class TimeTypeTest extends TestCase
|
|||||||
public function testSetDataWithSeconds()
|
public function testSetDataWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'UTC',
|
||||||
|
'view_timezone' => 'UTC',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -240,23 +257,53 @@ class TimeTypeTest extends TestCase
|
|||||||
$this->assertEquals(array('hour' => 3, 'minute' => 4, 'second' => 5), $form->getViewData());
|
$this->assertEquals(array('hour' => 3, 'minute' => 4, 'second' => 5), $form->getViewData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetDataWithTimezoneDateTime()
|
public function testSetDataDifferentTimezones()
|
||||||
{
|
{
|
||||||
date_default_timezone_set('Asia/Hong_Kong');
|
|
||||||
|
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'America/New_York',
|
||||||
|
'view_timezone' => 'Asia/Hong_Kong',
|
||||||
|
'input' => 'string',
|
||||||
|
'with_seconds' => true,
|
||||||
|
));
|
||||||
|
|
||||||
|
$dateTime = new \DateTime('2013-01-01 12:04:05');
|
||||||
|
$dateTime->setTimezone(new \DateTimeZone('America/New_York'));
|
||||||
|
|
||||||
|
$form->setData($dateTime->format('H:i:s'));
|
||||||
|
|
||||||
|
$outputTime = clone $dateTime;
|
||||||
|
$outputTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
|
||||||
|
|
||||||
|
$displayedData = array(
|
||||||
|
'hour' => (int) $outputTime->format('H'),
|
||||||
|
'minute' => (int) $outputTime->format('i'),
|
||||||
|
'second' => (int) $outputTime->format('s'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals($displayedData, $form->getViewData());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetDataDifferentTimezonesDateTime()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('time', null, array(
|
||||||
|
'model_timezone' => 'America/New_York',
|
||||||
|
'view_timezone' => 'Asia/Hong_Kong',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$dateTime = new \DateTime('12:04:05', new \DateTimeZone('America/New_York'));
|
$dateTime = new \DateTime('12:04:05');
|
||||||
|
$dateTime->setTimezone(new \DateTimeZone('America/New_York'));
|
||||||
|
|
||||||
$form->setData($dateTime);
|
$form->setData($dateTime);
|
||||||
|
|
||||||
|
$outputTime = clone $dateTime;
|
||||||
|
$outputTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
|
||||||
|
|
||||||
$displayedData = array(
|
$displayedData = array(
|
||||||
'hour' => 12,
|
'hour' => (int) $outputTime->format('H'),
|
||||||
'minute' => 4,
|
'minute' => (int) $outputTime->format('i'),
|
||||||
'second' => 5,
|
'second' => (int) $outputTime->format('s'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||||
|
Reference in New Issue
Block a user