localize: rm for span in

This commit is contained in:
James Campos 2011-05-27 04:43:15 -07:00
parent ab358bd17b
commit fa7ce06d53
2 changed files with 44 additions and 51 deletions

View File

@ -1670,34 +1670,28 @@
localize = { localize = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(function(root) {
var date, day, dotw, hour, meridiem, min_sec, month, s, span, year, _, _i, _len, _ref, _ref2, _results; var date, day, dotw, hour, meridiem, min_sec, month, s, year, _, _ref;
if (root.className === 'inline') { if (root.className === 'inline') {
return; return;
} }
_ref = $$('span[id^=no]', root); s = $('span[id^=no]', root).previousSibling;
_results = []; _ref = s.textContent.match(/(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\S+)/), _ = _ref[0], month = _ref[1], day = _ref[2], year = _ref[3], hour = _ref[4], min_sec = _ref[5];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { year = "20" + year;
span = _ref[_i]; month -= 1;
s = span.previousSibling; hour = g.chanOffset + Number(hour);
_ref2 = s.textContent.match(/(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\S+)/), _ = _ref2[0], month = _ref2[1], day = _ref2[2], year = _ref2[3], hour = _ref2[4], min_sec = _ref2[5]; date = new Date(year, month, day, hour);
year = "20" + year; year = date.getFullYear() - 2000;
month -= 1; month = $.zeroPad(date.getMonth() + 1);
hour = g.chanOffset + Number(hour); day = $.zeroPad(date.getDate());
date = new Date(year, month, day, hour); hour = date.getHours();
year = date.getFullYear() - 2000; meridiem = '';
month = $.zeroPad(date.getMonth() + 1); if ($.config('Localized am/pm')) {
day = $.zeroPad(date.getDate()); meridiem = hour < 12 ? ' a.m.' : ' p.m.';
hour = date.getHours(); hour = hour % 12 || 12;
meridiem = '';
if ($.config('Localized am/pm')) {
meridiem = hour < 12 ? ' a.m.' : ' p.m.';
hour = hour % 12 || 12;
}
hour = $.zeroPad(hour);
dotw = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()];
_results.push(s.textContent = " " + month + "/" + day + "/" + year + "(" + dotw + ")" + hour + ":" + min_sec + meridiem + " ");
} }
return _results; hour = $.zeroPad(hour);
dotw = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()];
return s.textContent = " " + month + "/" + day + "/" + year + "(" + dotw + ")" + hour + ":" + min_sec + meridiem + " ";
}); });
} }
}; };

View File

@ -1342,33 +1342,32 @@ localize =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push (root) ->
return if root.className is 'inline' return if root.className is 'inline'
for span in $$ 'span[id^=no]', root s = $('span[id^=no]', root).previousSibling
s = span.previousSibling [_, month, day, year, hour, min_sec] =
[_, month, day, year, hour, min_sec] = s.textContent.match /(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\S+)/
s.textContent.match /(\d+)\/(\d+)\/(\d+)\(\w+\)(\d+):(\S+)/ year = "20#{year}"
year = "20#{year}" month -= 1 #months start at 0
month -= 1 #months start at 0 hour = g.chanOffset + Number hour
hour = g.chanOffset + Number hour date = new Date year, month, day, hour
date = new Date year, month, day, hour year = date.getFullYear() - 2000
year = date.getFullYear() - 2000 month = $.zeroPad date.getMonth() + 1
month = $.zeroPad date.getMonth() + 1 day = $.zeroPad date.getDate()
day = $.zeroPad date.getDate() hour = date.getHours()
hour = date.getHours() meridiem = ''
meridiem = '' if $.config 'Localized am/pm'
if $.config 'Localized am/pm' meridiem = if hour < 12 then ' a.m.' else ' p.m.'
meridiem = if hour < 12 then ' a.m.' else ' p.m.' hour = hour % 12 or 12
hour = hour % 12 or 12 hour = $.zeroPad hour
hour = $.zeroPad hour dotw = [
dotw = [ 'Sun'
'Sun' 'Mon'
'Mon' 'Tue'
'Tue' 'Wed'
'Wed' 'Thu'
'Thu' 'Fri'
'Fri' 'Sat'
'Sat' ][date.getDay()]
][date.getDay()] s.textContent = " #{month}/#{day}/#{year}(#{dotw})#{hour}:#{min_sec}#{meridiem} "
s.textContent = " #{month}/#{day}/#{year}(#{dotw})#{hour}:#{min_sec}#{meridiem} "
titlePost = titlePost =
init: -> init: ->