Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3409
patch.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
•
bzimport
Nov 21 2014, 9:28 PM
2014-11-21 21:28:45 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
patch.diff
View Options
Index: GlobalFunctions.php
===================================================================
--- GlobalFunctions.php (revision 17237)
+++ GlobalFunctions.php (working copy)
@@ -81,6 +81,17 @@
}
}
+# Exists in PHP 5.1.0+
+if( !function_exists( 'date_default_timezone_get' ) ) {
+ function date_default_timezone_get() {
+ return getenv( 'TZ' );
+ }
+}
+if( !function_exists( 'date_default_timezone_set' ) ) {
+ function date_default_timezone_set( $setting ) {
+ return @putenv( 'TZ=' . $setting );
+ }
+}
/**
* Wrapper for clone(), for compatibility with PHP4-friendly extensions.
Index: Parser.php
===================================================================
--- Parser.php (revision 17237)
+++ Parser.php (working copy)
@@ -2351,8 +2351,8 @@
# Use the time zone
global $wgLocaltimezone;
if ( isset( $wgLocaltimezone ) ) {
- $oldtz = getenv( 'TZ' );
- putenv( 'TZ='.$wgLocaltimezone );
+ $oldtz = date_default_timezone_get();
+ date_default_timezone_set( $wgLocaltimezone );
}
$localTimestamp = date( 'YmdHis', $ts );
$localMonth = date( 'm', $ts );
@@ -2364,7 +2364,7 @@
$localYear = date( 'Y', $ts );
$localHour = date( 'H', $ts );
if ( isset( $wgLocaltimezone ) ) {
- putenv( 'TZ='.$oldtz );
+ date_default_timezone_set( $oldtz );
}
switch ( $index ) {
@@ -3626,13 +3626,13 @@
* than the one selected in each user's preferences.
*/
if ( isset( $wgLocaltimezone ) ) {
- $oldtz = getenv( 'TZ' );
- putenv( 'TZ='.$wgLocaltimezone );
+ $oldtz = date_default_timezone_get();
+ date_default_timezone_set( $wgLocaltimezone );
}
$d = $wgContLang->timeanddate( date( 'YmdHis' ), false, false) .
' (' . date( 'T' ) . ')';
if ( isset( $wgLocaltimezone ) ) {
- putenv( 'TZ='.$oldtz );
+ date_default_timezone_set( $oldtz );
}
# Variable replacement
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2977
Default Alt Text
patch.diff (1 KB)
Attached To
Mode
T9715: Use date_default_timezone_* instead of TZ environment variable if available
Attached
Detach File
Event Timeline
Log In to Comment