mirror of https://github.com/writeas/writefreely
A focused writing and publishing space.
https://write.with.parts
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
16 lines
697 B
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' });
|
|
}
|
|
|
|
// Adjust dates on individual post pages, and on posts in a list *with* an explicit title
|
|
var $dates = document.querySelectorAll("article > time");
|
|
for (var i=0; i < $dates.length; i++) {
|
|
toLocalDate($dates[i], $dates[i]);
|
|
}
|
|
|
|
// 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'));
|
|
} |