2020-01-29 12:42:32 +01:00
|
|
|
function toLocalDate(dateEl, displayEl) {
|
|
|
|
var d = new Date(dateEl.getAttribute("datetime"));
|
|
|
|
displayEl.textContent = d.toLocaleDateString(navigator.language || "en-US", { year: 'numeric', month: 'long', day: 'numeric' });
|
2019-10-03 18:47:08 +02:00
|
|
|
}
|
|
|
|
|
2020-01-29 12:42:32 +01:00
|
|
|
// Adjust dates on individual post pages, and on posts in a list *with* an explicit title
|
|
|
|
var $dates = document.querySelectorAll("article > time");
|
2019-10-03 18:47:08 +02:00
|
|
|
for (var i=0; i < $dates.length; i++) {
|
2020-01-29 12:42:32 +01:00
|
|
|
toLocalDate($dates[i], $dates[i]);
|
2019-10-03 18:47:08 +02:00
|
|
|
}
|
2020-01-29 12:42:32 +01:00
|
|
|
|
|
|
|
// Adjust dates on posts in a list without an explicit title, where they act as the header
|
|
|
|
$dates = document.querySelectorAll("h2.post-title > time");
|
|
|
|
for (i=0; i < $dates.length; i++) {
|
|
|
|
toLocalDate($dates[i], $dates[i].querySelector('a'));
|
|
|
|
}
|