Make Echo use pretty timestamps

Change-Id: I1b061840c720ece80c1301f8ee38da9c80f7d100
This commit is contained in:
Andrew Garrett 2012-07-16 17:05:29 -07:00
parent 92ba7da013
commit acd4ee2102
4 changed files with 13 additions and 2 deletions

View file

@ -64,11 +64,13 @@ class ApiEchoNotifications extends ApiQueryBase {
foreach( $res as $row ) { foreach( $res as $row ) {
$event = EchoEvent::newFromRow( $row ); $event = EchoEvent::newFromRow( $row );
global $wgLang;
$thisEvent = array( $thisEvent = array(
'type' => $event->getType(), 'type' => $event->getType(),
'timestamp' => array( 'timestamp' => array(
'unix' => wfTimestamp( TS_UNIX, $event->getTimestamp() ), 'unix' => wfTimestamp( TS_UNIX, $event->getTimestamp() ),
'mw' => $event->getTimestamp(), 'mw' => wfTimestamp( TS_MW, $event->getTimestamp() ),
'pretty' => $wgLang->prettyTimestamp( $event->getTimestamp() ),
), ),
); );

View file

@ -6,3 +6,7 @@
.mw-echo-unread { .mw-echo-unread {
background-color: #f9f9ff; background-color: #f9f9ff;
} }
div.mw-echo-timestamp {
text-align: right;
}

View file

@ -34,6 +34,11 @@
.data('id', id) .data('id', id)
.addClass('mw-echo-notification') .addClass('mw-echo-notification')
.append(data['*']) .append(data['*'])
.append(
$('<div></div>')
.text(data.timestamp.pretty)
.addClass('mw-echo-timestamp')
)
.appendTo($ul); .appendTo($ul);
if (! data.read ) { if (! data.read ) {

View file

@ -45,7 +45,7 @@ class SpecialNotifications extends SpecialPage {
$event = EchoEvent::newFromRow( $row ); $event = EchoEvent::newFromRow( $row );
$class = 'mw-echo-notification'; $class = 'mw-echo-notification';
$ts = $wgLang->timeanddate( $event->getTimestamp() ); $ts = $wgLang->prettyTimestamp( $event->getTimestamp() );
$formatted = "<span class='mw-echo-timestamp'>$ts</span> "; $formatted = "<span class='mw-echo-timestamp'>$ts</span> ";
$formatted .= EchoNotificationController::formatNotification( $event, $wgUser, 'html' ); $formatted .= EchoNotificationController::formatNotification( $event, $wgUser, 'html' );