FIX: null dates crashed the client app. last_posted_at was not updating properly on split topic.
This commit is contained in:
@@ -18,6 +18,8 @@ Discourse.Formatter = (function(){
|
||||
}
|
||||
|
||||
longDate = function(dt) {
|
||||
if (!dt) return;
|
||||
|
||||
return moment(dt).longDate();
|
||||
};
|
||||
|
||||
@@ -30,6 +32,9 @@ Discourse.Formatter = (function(){
|
||||
};
|
||||
|
||||
autoUpdatingRelativeAge = function(date,options) {
|
||||
|
||||
if (!date) return "";
|
||||
|
||||
options = options || {};
|
||||
var format = options.format || "tiny";
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ Handlebars.registerHelper('number', function(property, options) {
|
||||
@for Handlebars
|
||||
**/
|
||||
Handlebars.registerHelper('date', function(property, options) {
|
||||
var leaveAgo, val;
|
||||
var leaveAgo;
|
||||
if (property.hash) {
|
||||
if (property.hash.leaveAgo) {
|
||||
leaveAgo = property.hash.leaveAgo === "true";
|
||||
@@ -281,11 +281,11 @@ Handlebars.registerHelper('date', function(property, options) {
|
||||
property = property.hash.path;
|
||||
}
|
||||
}
|
||||
val = Ember.Handlebars.get(this, property, options);
|
||||
var date = null;
|
||||
var val = Ember.Handlebars.get(this, property, options);
|
||||
if (val) {
|
||||
date = new Date(val);
|
||||
var date = new Date(val);
|
||||
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(date, {format: 'medium', leaveAgo: leaveAgo}));
|
||||
}
|
||||
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(date, {format: 'medium', leaveAgo: leaveAgo}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user