0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 10:40:28 +01:00
discourse-custom-wizard/assets/javascripts/wizard/helpers/date-node.js.es6
Faizaan Gagan 0205d8ccb5
fixed linting issues for javascripts/wizard folder (#94)
* ran eslint and fixes linting issues for javascripts/wizard folder

* ran prettier
2021-04-12 11:56:22 +05:30

23 Zeilen
697 B
JavaScript

import { registerUnbound } from "discourse-common/lib/helpers";
import { longDate, relativeAge } from "discourse/lib/formatter";
import Handlebars from "handlebars";
export default registerUnbound("date-node", function (dt) {
if (typeof dt === "string") {
dt = new Date(dt);
}
if (dt) {
const attributes = {
title: longDate(dt),
"data-time": dt.getTime(),
"data-format": "tiny",
};
const finalString = `<span class="relative-date" title="${
attributes["title"]
}" data-time="${attributes["data-time"]}" data-format="${
attributes["data-format"]
}">${relativeAge(dt)}</span>`;
return new Handlebars.SafeString(finalString);
}
});