Round timestamps to the day when displaying date titles in Special:Notifications

Bug: T141915
Change-Id: I5fcb78ac2fa168aa8bba90c467544fe3a6914ec3
This commit is contained in:
Moriel Schottlender 2016-08-03 10:15:09 -07:00
parent c1e7fc2208
commit 8d3b4fad2c

View file

@ -12,7 +12,7 @@
* @param {Object} [config] Configuration object
*/
mw.echo.ui.DatedSubGroupListWidget = function MwEchoUiDatedSubGroupListWidget( controller, listModel, config ) {
var momentTimestamp, diff, fullDate,
var momentTimestamp, diff, fullDate, stringTimestamp,
now = moment(),
$primaryDate = $( '<span>' )
.addClass( 'mw-echo-ui-datedSubGroupListWidget-title-primary' ),
@ -42,9 +42,11 @@
}
}, config ) );
momentTimestamp = moment.utc( this.model.getTimestamp() );
// Round all dates to the day they're in, as if they all happened at 00:00h
stringTimestamp = moment.utc( this.model.getTimestamp() ).local().format( 'YYYY-MM-DD' );
momentTimestamp = moment( stringTimestamp );
diff = now.diff( momentTimestamp, 'weeks' );
fullDate = momentTimestamp.local().format( 'LL' );
fullDate = momentTimestamp.format( 'LL' );
$primaryDate.text( fullDate );
if ( diff === 0 ) {