[Form] check the required output timezone against the actual timezone

of the input datetime object, rather than the expected timezone supplied
This commit is contained in:
Bart van den Burg 2013-08-21 13:31:00 +02:00
parent 9c3c5d493f
commit b0349a19ee
2 changed files with 2 additions and 1 deletions

View File

@ -58,7 +58,7 @@ class DateTimeToRfc3339Transformer extends BaseDateTimeTransformer
throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
}
if ($this->outputTimezone !== $this->inputTimezone) {
if ($this->outputTimezone !== $dateTime->getTimezone()->getName()) {
try {
$dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));
} catch (\Exception $e) {

View File

@ -65,6 +65,7 @@ class DateTimeToRfc3339TransformerTest extends DateTimeTestCase
// format without seconds, as appears in some browsers
array('UTC', 'UTC', '2010-02-03 04:05:00 UTC', '2010-02-03T04:05Z'),
array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:00 America/New_York', '2010-02-03T17:05+08:00'),
array('Europe/Amsterdam', 'Europe/Amsterdam', '2013-08-21 10:30:00 Europe/Amsterdam', '2013-08-21T08:30:00Z')
));
}