diff --git a/4chan_x.user.js b/4chan_x.user.js index 919f54ff2..fc49b2383 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2196,16 +2196,20 @@ return g.callbacks.push(Time.node); }, node: function(root) { - var day, hour, min, month, node, posttime, time, year, _, _ref; + var day, hour, min, month, node, parse, posttime, time, year, _, _ref; 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); + if (parse = Date.parse(node.textContent)) { + Time.date = new Date(parse + g.chanOffset * HOUR); + } else { + _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 = $.el('time', { textContent: ' ' + Time.funk(Time) + ' ' }); diff --git a/script.coffee b/script.coffee index ec9615d5b..88668774b 100644 --- a/script.coffee +++ b/script.coffee @@ -1663,13 +1663,16 @@ 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 + if parse = Date.parse node.textContent + Time.date = new Date parse + g.chanOffset*HOUR + else # Firefox the Archaic cannot parse 4chan's time + [_, 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 = $.el 'time', textContent: ' ' + Time.funk(Time) + ' '