Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Draft Forbes Group Website (Build by Nikola). The official site is hosted at:

https://labs.wsu.edu/forbes

5912 views
License: GPL3
ubuntu2004
1
function fancydates(fanciness, luxonDateFormat) {
2
if (fanciness === 0) {
3
return;
4
}
5
6
var dates = document.querySelectorAll('.dt-published, .dt-updated, .listdate');
7
8
var l = dates.length;
9
10
for (var i = 0; i < l; i++) {
11
var d = luxon.DateTime.fromISO(dates[i].attributes.datetime.value);
12
var o;
13
if (fanciness === 1 && luxonDateFormat.preset) {
14
o = d.toLocal().toLocaleString(luxon.DateTime[luxonDateFormat.format]);
15
} else if (fanciness === 1) {
16
o = d.toLocal().toFormat(luxonDateFormat.format);
17
} else {
18
o = d.toRelative();
19
}
20
dates[i].innerHTML = o;
21
}
22
}
23
24