2019-11-01 12:30:19 +11:00
|
|
|
import { registerUnbound } from "discourse-common/lib/helpers";
|
|
|
|
|
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
|
2020-05-06 19:06:14 -03:00
|
|
|
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());
|
|
|
|
|
|
2020-05-06 19:06:14 -03:00
|
|
|
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
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|