mirror of
https://github.com/writefreely/writefreely
synced 2024-11-24 17:43:05 +00:00
Merge pull request #191 from writeas/T670-local-time
show timestamps in local date/locale
This commit is contained in:
commit
93dd2341c2
7 changed files with 22 additions and 1 deletions
16
static/js/localdate.js
Normal file
16
static/js/localdate.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
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'));
|
||||
}
|
|
@ -83,6 +83,7 @@ body#post header {
|
|||
{{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;
|
||||
|
|
|
@ -115,6 +115,7 @@ body#collection header nav.tabs a:first-child {
|
|||
{{if .Script}}<script type="text/javascript">{{.ScriptDisplay}}</script>{{end}}
|
||||
{{end}}
|
||||
<script src="/js/h.js"></script>
|
||||
<script src="/js/localdate.js"></script>
|
||||
<script src="/js/postactions.js"></script>
|
||||
<script type="text/javascript">
|
||||
var deleting = false;
|
||||
|
|
|
@ -73,6 +73,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;
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
{{end}}
|
||||
{{if .IsOwner}}
|
||||
<script src="/js/h.js"></script>
|
||||
<script src="/js/localdate.js"></script>
|
||||
<script src="/js/postactions.js"></script>
|
||||
{{end}}
|
||||
<script type="text/javascript">
|
||||
|
|
|
@ -116,6 +116,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) {
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
</nav>{{end}}
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/js/localdate.js">
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var $articles = document.querySelectorAll('article');
|
||||
|
|
Loading…
Reference in a new issue