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

17 lines
440 B
JavaScript

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
})
);
}
});