use calendar date formatting for all languages but EN_US - fixes #944

icc-ip-api
Thibault Duplessis 2015-09-12 17:20:52 +02:00
parent 0dbe4e5741
commit b97f071388
2 changed files with 5 additions and 2 deletions

View File

@ -69,7 +69,7 @@ trait DateHelper { self: I18nHelper =>
def momentFormat(date: DateTime, format: String): Html = Html {
s"""<time class="moment" datetime="${isoDate(date)}" data-format="$format"></time>"""
}
def momentFormat(date: DateTime): Html = momentFormat(date, "DD MMM YYYY")
def momentFormat(date: DateTime): Html = momentFormat(date, "calendar")
def momentFromNow(date: DateTime)(implicit ctx: Context) = Html {
s"""<time class="moment-from-now" title="${showDate(date)}" datetime="${isoDate(date)}"></time>"""

View File

@ -752,11 +752,14 @@ lichess.desktopNotification = function(msg) {
});
});
var documentLang;
function setMoment() {
documentLang = documentLang || $('html').attr('lang');
$("time.moment").removeClass('moment').each(function() {
var parsed = moment(this.getAttribute('datetime'));
var format = this.getAttribute('data-format');
this.textContent = format == 'calendar' ? parsed.calendar() : parsed.format(format);
if (format === 'calendar' && documentLang === 'en') format = 'DD MMM YYYY';
this.textContent = format === 'calendar' ? parsed.calendar() : parsed.format(format);
});
}
setMoment();