Merge pull request #2706 from techAPJ/patch-2

FIX: use short date format for timestamp
This commit is contained in:
Jeff Atwood 2014-08-27 00:42:56 -07:00
commit b3d896723b
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,