discourse-subscriptions/assets/javascripts/discourse/helpers/format-unix-date.js.es6

17 lines
440 B
Plaintext
Raw Normal View History

2019-10-31 21:30:19 -04:00
import { registerUnbound } from "discourse-common/lib/helpers";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
registerUnbound("format-unix-date", function(timestamp) {
if (timestamp) {
const date = new Date(moment.unix(timestamp).format());
return new Handlebars.SafeString(
autoUpdatingRelativeAge(date, {
format: "medium",
title: true,
leaveAgo: true
})
);
}
});