FIX: use short date format for timestamp

This commit is contained in:
Arpit Jalan 2014-08-27 11:38:17 +05:30
parent 898d86fd9b
commit 0453da6fa5
2 changed files with 14 additions and 2 deletions

View File

@ -162,7 +162,7 @@ Handlebars.registerHelper('raw-date', function(property, options) {
@for Handlebars
**/
Em.Handlebars.helper('bound-raw-date', function (date) {
return Discourse.Formatter.longDate(new Date(date));
return Discourse.Formatter.longDateNoYear(new Date(date));
});
/**

View File

@ -1,7 +1,7 @@
/* global BreakString:true */
var updateRelativeAge, autoUpdatingRelativeAge, relativeAge, relativeAgeTiny,
relativeAgeMedium, relativeAgeMediumSpan, longDate, toTitleCase,
relativeAgeMedium, relativeAgeMediumSpan, longDate, longDateNoYear, toTitleCase,
shortDate, shortDateNoYear, tinyDateYear, relativeAgeTinyShowsYear;
/*
@ -75,6 +75,17 @@ longDate = function(dt) {
return moment(dt).longDate();
};
// suppress year, if current year
longDateNoYear = function(dt) {
if (!dt) return;
if ((new Date()).getFullYear() !== dt.getFullYear()) {
return moment(dt).format("MMM D, 'YY LT");
} else {
return moment(dt).format("MMM D, LT");
}
};
updateRelativeAge = function(elems) {
// jQuery .each
elems.each(function(){
@ -258,6 +269,7 @@ var number = function(val) {
Discourse.Formatter = {
longDate: longDate,
longDateNoYear: longDateNoYear,
relativeAge: relativeAge,
autoUpdatingRelativeAge: autoUpdatingRelativeAge,
updateRelativeAge: updateRelativeAge,