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

18 lines
473 B
JavaScript

import { registerUnbound } from "discourse-common/lib/helpers";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
import { htmlSafe } from "@ember/template";
registerUnbound("format-unix-date", function (timestamp) {
if (timestamp) {
const date = new Date(moment.unix(timestamp).format());
return new htmlSafe(
autoUpdatingRelativeAge(date, {
format: "medium",
title: true,
leaveAgo: true,
})
);
}
});