Skip to content

Commit

Permalink
localize datetimes (#6,#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
aureliendavid committed Dec 14, 2018
1 parent 2a1ba1e commit aff27e2
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions rsspreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,38 @@
}


function getlang() {
if (navigator.languages && navigator.languages[0])
return navigator.languages[0];
else if (navigator.language)
return navigator.language;
else
return null;
}

function formatdates() {

var lang = getlang();
if (!lang)
return;

var opts = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };

var ed = document.getElementsByClassName("lastUpdated");
for (var i = 0; i<ed.length; i++) {

var d = new Date(ed[i].innerText);
if (isNaN(d))
continue;

var dstr = d.toLocaleDateString(lang, opts) + ' ' + d.toLocaleTimeString(lang);
ed[i].innerText = dstr;

}

}


function addfeedurl(url) {

var h1 = document.getElementById("feedTitleText");
Expand Down Expand Up @@ -261,6 +293,7 @@
formatfilenames();
formatfilesizes();
formattitles();
formatdates();
extensionimages();

document.title = /*"RSSPreview: " + */document.getElementById("feedTitleText").innerText;
Expand Down

0 comments on commit aff27e2

Please sign in to comment.