mirror of
https://github.com/discourse/discourse.git
synced 2025-02-09 11:49:47 +08:00
27 lines
674 B
JavaScript
27 lines
674 B
JavaScript
import registerUnbound from 'discourse/helpers/register-unbound';
|
|
|
|
/**
|
|
Display logic for dates. It is unbound in Ember but will use jQuery to
|
|
update the dates on a regular interval.
|
|
**/
|
|
registerUnbound('format-date', function(val, params) {
|
|
var leaveAgo,
|
|
format = 'medium',
|
|
title = true;
|
|
|
|
if (params.leaveAgo) {
|
|
leaveAgo = params.leaveAgo === "true";
|
|
}
|
|
if (params.format) {
|
|
format = params.format;
|
|
}
|
|
if (params.noTitle) {
|
|
title = false;
|
|
}
|
|
|
|
if (val) {
|
|
var date = new Date(val);
|
|
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(date, {format: format, title: title, leaveAgo: leaveAgo}));
|
|
}
|
|
});
|