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
This commit is contained in:
Matthias Mullie 2015-12-22 17:07:30 +01:00
parent fe9db1b78c
commit 089d922ac7
3 changed files with 4 additions and 2 deletions

View file

@ -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
),

View file

@ -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

View file

@ -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,