From 2e43059f3e6d2c928e5ba8d5dd0924bed9957a0c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 11 Oct 2011 14:32:42 +0200 Subject: [PATCH] Time formatting boost. God damn, that was easy. --- 4chan_x.user.js | 8 ++------ script.coffee | 9 +-------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d2f2a7bbf..b0f635309 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2203,16 +2203,12 @@ return g.callbacks.push(Time.node); }, node: function(root) { - var day, hour, min, month, node, posttime, time, year, _, _ref; + var node, posttime, time; if (root.className === 'inline') { return; } 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]; - year = "20" + year; - month -= 1; - hour = g.chanOffset + Number(hour); - Time.date = new Date(year, month, day, hour, min); + Time.date = new Date(Date.parse(node.textContent) + g.chanOffset * HOUR); time = $.el('time', { textContent: ' ' + Time.funk(Time) + ' ' }); diff --git a/script.coffee b/script.coffee index 8b325e807..35154d53f 100644 --- a/script.coffee +++ b/script.coffee @@ -1669,14 +1669,7 @@ Time = node: (root) -> return if root.className is 'inline' node = if posttime = $('.posttime', root) then posttime else $('span[id]', root).previousSibling - [_, month, day, year, hour, min] = - 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.date = new Date Date.parse(node.textContent) + g.chanOffset*HOUR time = $.el 'time', textContent: ' ' + Time.funk(Time) + ' ' $.replace node, time