Browse Source

local-time.js: don't use jQuery

pull/40/head
Michael Save 12 years ago
parent
commit
c0876c4e86
  1. 21
      js/local-time.js

21
js/local-time.js

@ -12,7 +12,7 @@
* *
*/ */
$(document).ready(function(){ onload(function(){
var iso8601 = function(s) { var iso8601 = function(s) {
s = s.replace(/\.\d\d\d+/,""); // remove milliseconds s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
s = s.replace(/-/,"/").replace(/-/,"/"); s = s.replace(/-/,"/").replace(/-/,"/");
@ -24,19 +24,22 @@ $(document).ready(function(){
return [Math.pow(10, count - num.toString().length), num].join('').substr(1); return [Math.pow(10, count - num.toString().length), num].join('').substr(1);
}; };
$('time').each(function() { var times = document.getElementsByTagName('time');
if(!$(this).text().match(/^\d+\/\d+\/\d+ \(\w+\) \d+:\d+:\d+$/))
return; for(var i = 0; i < times.length; i++) {
if(!times[i].innerHTML.match(/^\d+\/\d+\/\d+ \(\w+\) \d+:\d+:\d+$/))
continue;
var t = iso8601(times[i].getAttribute('datetime'));
var t = iso8601($(this).attr('datetime'));
$(this).text(
times[i].innerHTML =
// date // date
zeropad(t.getMonth() + 1, 2) + "/" + zeropad(t.getDate(), 2) + "/" + t.getFullYear().toString().substring(2) + zeropad(t.getMonth() + 1, 2) + "/" + zeropad(t.getDate(), 2) + "/" + t.getFullYear().toString().substring(2) +
" (" + ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][t.getDay()] + ") " + " (" + ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][t.getDay()] + ") " +
// time // time
zeropad(t.getHours(), 2) + ":" + zeropad(t.getMinutes(), 2) + ":" + zeropad(t.getSeconds(), 2) zeropad(t.getHours(), 2) + ":" + zeropad(t.getMinutes(), 2) + ":" + zeropad(t.getSeconds(), 2);
); };
});
}); });

Loading…
Cancel
Save