A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

16 lines
697 B

  1. function toLocalDate(dateEl, displayEl) {
  2. var d = new Date(dateEl.getAttribute("datetime"));
  3. displayEl.textContent = d.toLocaleDateString(navigator.language || "en-US", { year: 'numeric', month: 'long', day: 'numeric' });
  4. }
  5. // Adjust dates on individual post pages, and on posts in a list *with* an explicit title
  6. var $dates = document.querySelectorAll("article > time");
  7. for (var i=0; i < $dates.length; i++) {
  8. toLocalDate($dates[i], $dates[i]);
  9. }
  10. // Adjust dates on posts in a list without an explicit title, where they act as the header
  11. $dates = document.querySelectorAll("h2.post-title > time");
  12. for (i=0; i < $dates.length; i++) {
  13. toLocalDate($dates[i], $dates[i].querySelector('a'));
  14. }