Time formatting boost. God damn, that was easy.

This commit is contained in:
Nicolas Stepien 2011-10-11 14:32:42 +02:00
parent e43d6d4431
commit 2e43059f3e
2 changed files with 3 additions and 14 deletions

View File

@ -2203,16 +2203,12 @@
return g.callbacks.push(Time.node); return g.callbacks.push(Time.node);
}, },
node: function(root) { node: function(root) {
var day, hour, min, month, node, posttime, time, year, _, _ref; var node, posttime, time;
if (root.className === 'inline') { if (root.className === 'inline') {
return; return;
} }
node = (posttime = $('.posttime', root)) ? posttime : $('span[id]', root).previousSibling; node = (posttime = $('.posttime', root)) ? posttime : $('span[id]', root).previousSibling;
_ref = node.textContent.match(/(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\d+)/), _ = _ref[0], month = _ref[1], day = _ref[2], year = _ref[3], hour = _ref[4], min = _ref[5]; Time.date = new Date(Date.parse(node.textContent) + g.chanOffset * HOUR);
year = "20" + year;
month -= 1;
hour = g.chanOffset + Number(hour);
Time.date = new Date(year, month, day, hour, min);
time = $.el('time', { time = $.el('time', {
textContent: ' ' + Time.funk(Time) + ' ' textContent: ' ' + Time.funk(Time) + ' '
}); });

View File

@ -1669,14 +1669,7 @@ Time =
node: (root) -> node: (root) ->
return if root.className is 'inline' return if root.className is 'inline'
node = if posttime = $('.posttime', root) then posttime else $('span[id]', root).previousSibling node = if posttime = $('.posttime', root) then posttime else $('span[id]', root).previousSibling
[_, month, day, year, hour, min] = Time.date = new Date Date.parse(node.textContent) + g.chanOffset*HOUR
node.textContent.match /(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\d+)/
year = "20#{year}"
month -= 1 #months start at 0
hour = g.chanOffset + Number hour
Time.date = new Date year, month, day, hour, min
#XXX /b/ will have seconds cut off
time = $.el 'time', time = $.el 'time',
textContent: ' ' + Time.funk(Time) + ' ' textContent: ' ' + Time.funk(Time) + ' '
$.replace node, time $.replace node, time