[Yaml] fix default timezone to be UTC

This commit is contained in:
Christian Flothmann 2016-02-17 22:15:58 +01:00
parent 1dcf83c35b
commit e9ee877e4b
3 changed files with 9 additions and 4 deletions

View File

@ -475,7 +475,12 @@ class Inline
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
return (float) str_replace(',', '', $scalar);
case preg_match(self::getTimestampRegex(), $scalar):
return strtotime($scalar);
$timeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$time = strtotime($scalar);
date_default_timezone_set($timeZone);
return $time;
}
default:
return (string) $scalar;

View File

@ -752,7 +752,7 @@ yaml: |
Billsmer @ 338-4338.
php: |
array(
'invoice' => 34843, 'date' => mktime(0, 0, 0, 1, 23, 2001),
'invoice' => 34843, 'date' => gmmktime(0, 0, 0, 1, 23, 2001),
'bill-to' =>
array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
, 'ship-to' =>
@ -877,7 +877,7 @@ yaml: |
php: |
array(
'invoice' => 34843,
'date' => mktime(0, 0, 0, 1, 23, 2001),
'date' => gmmktime(0, 0, 0, 1, 23, 2001),
'total' => 4443.52
)
---

View File

@ -202,7 +202,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
"'on'" => 'on',
"'off'" => 'off',
'2007-10-30' => mktime(0, 0, 0, 10, 30, 2007),
'2007-10-30' => gmmktime(0, 0, 0, 10, 30, 2007),
'2007-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 2007),
'2007-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 2007),
'1960-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 1960),