A new Riff-radio.org site with a static approach.

fancydates.js 677B

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