diff --git a/Echo.i18n.php b/Echo.i18n.php index 31ef5fc87..1ca916fae 100644 --- a/Echo.i18n.php +++ b/Echo.i18n.php @@ -159,7 +159,6 @@ $1', // Special page 'echo-date-today' => 'Today', 'echo-date-yesterday' => 'Yesterday', - 'echo-date-header' => '$1 $2', 'echo-load-more-error' => 'An error occurred while fetching more results.', // Bundle @@ -504,10 +503,6 @@ The new notification count next to notification link, for example: 99+ 'echo-date-today' => "The header text for today's notification section. {{Identical|Today}}", 'echo-date-yesterday' => "The header text for yesterday's notification section", - 'echo-date-header' => '{{optional}} -The header text for each notification section which is grouped by date -* $1 is the month, it could be {{msg-mw|january-gen}}, {{msg-mw|february-gen}}, {{msg-mw|march-gen}}, {{msg-mw|april-gen}}, {{msg-mw|may-gen}}, {{msg-mw|june-gen}}, {{msg-mw|july-gen}}, {{msg-mw|august-gen}}, {{msg-mw|september-gen}}, {{msg-mw|october-gen}}, {{msg-mw|november-gen}}, {{msg-mw|december-gen}} -* $2 is the date of a month, eg 21', 'echo-load-more-error' => 'Error message for errors in loading more notifications', 'notification-edit-talk-page-bundle' => 'Bundled message for edit-user-talk notification. Parameters: * $1 - the username who performs the action, which can be used for gender support diff --git a/api/ApiEchoNotifications.php b/api/ApiEchoNotifications.php index 5bc330863..5e6d5e39f 100644 --- a/api/ApiEchoNotifications.php +++ b/api/ApiEchoNotifications.php @@ -84,38 +84,28 @@ class ApiEchoNotifications extends ApiQueryBase { } $timestamp = new MWTimestamp( $row->notification_timestamp ); + // Adjust for the user's timezone + $timestamp->offsetForUser( $user ); $timestampUnix = $timestamp->getTimestamp( TS_UNIX ); $timestampMw = $timestamp->getTimestamp( TS_MW ); - // start creating date section header + // Start creating date section header $today = wfTimestamp( TS_MW ); $yesterday = wfTimestamp( TS_MW, wfTimestamp( TS_UNIX, $today ) - 24 * 3600 ); if ( substr( $today, 0, 8 ) === substr( $timestampMw, 0, 8 ) ) { + // 'Today' $date = wfMessage( 'echo-date-today' )->escaped(); } elseif ( substr( $yesterday, 0, 8 ) === substr( $timestampMw, 0, 8 ) ) { + // 'Yesterday' $date = wfMessage( 'echo-date-yesterday' )->escaped(); } else { - $month = array( - '01' => 'january-gen', - '02' => 'february-gen', - '03' => 'march-gen', - '04' => 'april-gen', - '05' => 'may-gen', - '06' => 'june-gen', - '07' => 'july-gen', - '08' => 'august-gen', - '09' => 'september-gen', - '10' => 'october-gen', - '11' => 'november-gen', - '12' => 'december-gen' - ); - - $headerMonth = wfMessage( $month[substr( $timestampMw, 4, 2 )] )->text(); - $headerDate = substr( $timestampMw, 6, 2 ); - $date = wfMessage( 'echo-date-header' )->params( $headerMonth )->numParams( $headerDate )->escaped(); + // 'May 10' or '10 May' (depending on user's date format preference) + $lang = RequestContext::getMain()->getLanguage(); + $dateFormat = $lang->getDateFormatString( 'pretty', $user->getDatePreference() ?: 'default' ); + $date = $lang->sprintfDate( $dateFormat, $timestampMw ); } - // end creating date section header + // End creating date section header $thisEvent = array( 'id' => $event->getId(),