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