mirror of
https://github.com/writeas/writefreely
synced 2024-12-12 08:36:14 +01:00
caca8f0ae2
this adds a helper script to rewrite all time elements with a proper datetime attribute into the users locale via the browser navigator.language. collection, collection-post and chorus-collection-post templates now include this script
10 lines
316 B
JavaScript
10 lines
316 B
JavaScript
function toLocalDate(el) {
|
|
var d = new Date(el.getAttribute("datetime"));
|
|
el.textContent = d.toLocaleDateString(navigator.language || "en-US", { year: 'numeric', month: 'long', day: 'numeric' });
|
|
}
|
|
|
|
var $dates = document.querySelectorAll("time");
|
|
for (var i=0; i < $dates.length; i++) {
|
|
toLocalDate($dates[i]);
|
|
}
|