Adamw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/74655


Change subject: make date code less horrifying
......................................................................

make date code less horrifying

Change-Id: Ie58ae4773ddea9684dfe28131439d3cadc5f8caa
---
M sites/all/modules/wmf_common/wmf_dates.php
1 file changed, 4 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/55/74655/1

diff --git a/sites/all/modules/wmf_common/wmf_dates.php 
b/sites/all/modules/wmf_common/wmf_dates.php
index ad38e51..5eaaf11 100644
--- a/sites/all/modules/wmf_common/wmf_dates.php
+++ b/sites/all/modules/wmf_common/wmf_dates.php
@@ -66,16 +66,13 @@
  * @param integer $unixtime timestamp, seconds since epoch
  */
 function wmf_common_date_format_using_utc( $format, $unixtime ) {
-    $oldTimezone = date_default_timezone_get();
-    date_default_timezone_set( "UTC" );
-
     try {
-        $formatted = date( $format, $unixtime );
+        $obj = new DateTime( '@' . $unixtime, new DateTimeZone( 'UTC' ) );
+        $formatted = $obj->format( $format );
     } catch ( Exception $ex ) {
-        watchdog( 'wmf_common', t( "Caught 'impossible' exception from date(): 
" ) . $ex->getMessage(), WATCHDOG_ERROR );
+        watchdog( 'wmf_common', t( "Caught date exception: " ) . 
$ex->getMessage(), WATCHDOG_ERROR );
+        return '';
     }
-
-    date_default_timezone_set( $oldTimezone );
 
     return $formatted;
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/74655
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie58ae4773ddea9684dfe28131439d3cadc5f8caa
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to