mirror of https://github.com/writeas/writefreely
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 scriptpull/191/head
parent
3759f16ed3
commit
caca8f0ae2
@ -0,0 +1,9 @@ |
|||||||
|
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]); |
||||||
|
} |
Loading…
Reference in new issue