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

Commit e9ee877

Browse filesBrowse files
committed
[Yaml] fix default timezone to be UTC
1 parent 1dcf83c commit e9ee877
Copy full SHA for e9ee877

File tree

3 files changed

+9
-4
lines changed
Filter options

3 files changed

+9
-4
lines changed

‎src/Symfony/Component/Yaml/Inline.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Inline.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,12 @@ private static function evaluateScalar($scalar, $references = array())
475475
case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar):
476476
return (float) str_replace(',', '', $scalar);
477477
case preg_match(self::getTimestampRegex(), $scalar):
478-
return strtotime($scalar);
478+
$timeZone = date_default_timezone_get();
479+
date_default_timezone_set('UTC');
480+
$time = strtotime($scalar);
481+
date_default_timezone_set($timeZone);
482+
483+
return $time;
479484
}
480485
default:
481486
return (string) $scalar;

‎src/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ yaml: |
752752
Billsmer @ 338-4338.
753753
php: |
754754
array(
755-
'invoice' => 34843, 'date' => mktime(0, 0, 0, 1, 23, 2001),
755+
'invoice' => 34843, 'date' => gmmktime(0, 0, 0, 1, 23, 2001),
756756
'bill-to' =>
757757
array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
758758
, 'ship-to' =>
@@ -877,7 +877,7 @@ yaml: |
877877
php: |
878878
array(
879879
'invoice' => 34843,
880-
'date' => mktime(0, 0, 0, 1, 23, 2001),
880+
'date' => gmmktime(0, 0, 0, 1, 23, 2001),
881881
'total' => 4443.52
882882
)
883883
---

‎src/Symfony/Component/Yaml/Tests/InlineTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/InlineTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ protected function getTestsForParse()
202202
"'on'" => 'on',
203203
"'off'" => 'off',
204204

205-
'2007-10-30' => mktime(0, 0, 0, 10, 30, 2007),
205+
'2007-10-30' => gmmktime(0, 0, 0, 10, 30, 2007),
206206
'2007-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 2007),
207207
'2007-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 2007),
208208
'1960-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 1960),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.