show timestamps in local date/locale
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
This commit is contained in:
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]);
|
||||
}
|
|
@ -90,6 +90,7 @@ article time.dt-published {
|
|||
{{range .Collection.ExternalScripts}}<script type="text/javascript" src="{{.}}" async></script>{{end}}
|
||||
{{if .Collection.Script}}<script type="text/javascript">{{.Collection.ScriptDisplay}}</script>{{end}}
|
||||
{{end}}
|
||||
<script src="/js/localdate.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var pinning = false;
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
{{range .Collection.ExternalScripts}}<script type="text/javascript" src="{{.}}" async></script>{{end}}
|
||||
{{if .Collection.Script}}<script type="text/javascript">{{.Collection.ScriptDisplay}}</script>{{end}}
|
||||
{{end}}
|
||||
<script src="/js/localdate.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var pinning = false;
|
||||
|
|
|
@ -113,6 +113,7 @@
|
|||
{{end}}
|
||||
<script src="/js/h.js"></script>
|
||||
<script src="/js/postactions.js"></script>
|
||||
<script src="/js/localdate.js"></script>
|
||||
<script type="text/javascript">
|
||||
var deleting = false;
|
||||
function delPost(e, id, owned) {
|
||||
|
|
Loading…
Reference in New Issue