From 089d922ac76718c563d0c37e3c655dfd981f40aa Mon Sep 17 00:00:00 2001 From: Matthias Mullie Date: Tue, 22 Dec 2015 17:07:30 +0100 Subject: [PATCH] Use UTC timestamps in flyout We already output unix timestamp both in user preference timezone as well as utc, but we only had the user timezone version for TS_MW format. While we could change the frontend to use the unix timestamp format, I don't see any reason not to also include the MW format in utc. Frontend can now easily use that. Also fixed creation of the moment object. The timestamp was created as UTC, but the way it got there was wrong: it expects the timezone offset (Z) to be included in the timestamp, which is not the case (so it just ended up at +0:00, which was fine, but confusing). I removed the 'Z' and forced it to be interpreted as utc. Bug: T121813 Change-Id: I09403615a1ffbde5dd69af9914afdbdd86cbfe4d --- includes/DataOutputFormatter.php | 2 ++ modules/ooui/mw.echo.ui.NotificationItemWidget.js | 2 +- modules/viewmodel/mw.echo.dm.NotificationsModel.js | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/DataOutputFormatter.php b/includes/DataOutputFormatter.php index 02a21cfb7..c3af36027 100644 --- a/includes/DataOutputFormatter.php +++ b/includes/DataOutputFormatter.php @@ -34,6 +34,7 @@ class EchoDataOutputFormatter { $event = $notification->getEvent(); $timestamp = $notification->getTimestamp(); $utcTimestampUnix = wfTimestamp( TS_UNIX, $timestamp ); + $utcTimestampMW = wfTimestamp( TS_MW, $timestamp ); if ( $notification->getBundleBase() && $notification->getBundleDisplayHash() ) { $event->setBundleHash( $notification->getBundleDisplayHash() ); @@ -68,6 +69,7 @@ class EchoDataOutputFormatter { // UTC timestamp in UNIX format used for loading more notification 'utcunix' => $utcTimestampUnix, 'unix' => self::getUserLocalTime( $user, $timestamp, TS_UNIX ), + 'utcmw' => $utcTimestampMW, 'mw' => $timestampMw, 'date' => $date ), diff --git a/modules/ooui/mw.echo.ui.NotificationItemWidget.js b/modules/ooui/mw.echo.ui.NotificationItemWidget.js index 9e7201842..7ec907efb 100644 --- a/modules/ooui/mw.echo.ui.NotificationItemWidget.js +++ b/modules/ooui/mw.echo.ui.NotificationItemWidget.js @@ -89,7 +89,7 @@ // Timestamp this.timestampWidget = new OO.ui.LabelWidget( { classes: [ 'mw-echo-ui-notificationItemWidget-content-actions-timestamp' ], - label: moment( this.model.getTimestamp(), 'YYYYMMDDHHmmss Z' ).fromNow() + label: moment.utc( this.model.getTimestamp(), 'YYYYMMDDHHmmss' ).fromNow() } ); // Build the actions line diff --git a/modules/viewmodel/mw.echo.dm.NotificationsModel.js b/modules/viewmodel/mw.echo.dm.NotificationsModel.js index f2f075d71..870c522ac 100644 --- a/modules/viewmodel/mw.echo.dm.NotificationsModel.js +++ b/modules/viewmodel/mw.echo.dm.NotificationsModel.js @@ -432,7 +432,7 @@ newNotifData = { read: !!notifData.read, seen: !!notifData.read || notifData.timestamp.mw <= model.getSeenTime(), - timestamp: notifData.timestamp.mw, + timestamp: notifData.timestamp.utcmw, category: notifData.category, content: { header: content.header,