Files

18 lines
473 B
JavaScript
Raw Permalink Normal View History

2019-11-01 12:30:19 +11:00
import { registerUnbound } from "discourse-common/lib/helpers";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
import { htmlSafe } from "@ember/template";
2019-11-01 12:30:19 +11:00
2020-09-16 09:53:50 -05:00
registerUnbound("format-unix-date", function (timestamp) {
2019-11-01 12:30:19 +11:00
if (timestamp) {
const date = new Date(moment.unix(timestamp).format());
return new htmlSafe(
2019-11-01 12:30:19 +11:00
autoUpdatingRelativeAge(date, {
format: "medium",
title: true,
2020-09-16 09:53:50 -05:00
leaveAgo: true,
2019-11-01 12:30:19 +11:00
})
);
}
});