update recursive calls to strftime, fix indentation

This commit is contained in:
Sami Samhuri 2011-06-08 01:02:10 -07:00
parent 70445ffc9a
commit 1ee97604bb

View file

@ -67,7 +67,7 @@
d = new Date(d.getTime() + msDelta); d = new Date(d.getTime() + msDelta);
} }
// Most of the specifiers supported by C's strftime // Most of the specifiers supported by C's strftime, and one from Ruby (%L)
return fmt.replace(/%(.)/g, function(_, c) { return fmt.replace(/%(.)/g, function(_, c) {
switch (c) { switch (c) {
case 'A': return locale.days[d.getDay()]; case 'A': return locale.days[d.getDay()];
@ -75,10 +75,10 @@
case 'B': return locale.months[d.getMonth()]; case 'B': return locale.months[d.getMonth()];
case 'b': // fall through case 'b': // fall through
case 'h': return locale.shortMonths[d.getMonth()]; case 'h': return locale.shortMonths[d.getMonth()];
case 'D': return strftime(locale.formats.D || '%m/%d/%y', d, locale); case 'D': return _strftime(locale.formats.D || '%m/%d/%y', d, locale);
case 'd': return pad(d.getDate()); case 'd': return pad(d.getDate());
case 'e': return d.getDate(); case 'e': return d.getDate();
case 'F': return strftime(locale.formats.F || '%Y-%m-%d', d, locale); case 'F': return _strftime(locale.formats.F || '%Y-%m-%d', d, locale);
case 'H': return pad(d.getHours()); case 'H': return pad(d.getHours());
case 'I': return pad(hours12(d)); case 'I': return pad(hours12(d));
case 'k': return pad(d.getHours(), ' '); case 'k': return pad(d.getHours(), ' ');
@ -88,16 +88,16 @@
case 'm': return pad(d.getMonth() + 1); case 'm': return pad(d.getMonth() + 1);
case 'n': return '\n'; case 'n': return '\n';
case 'p': return d.getHours() < 12 ? locale.AM : locale.PM; case 'p': return d.getHours() < 12 ? locale.AM : locale.PM;
case 'R': return strftime(locale.formats.R || '%H:%M', d, locale); case 'R': return _strftime(locale.formats.R || '%H:%M', d, locale);
case 'r': return strftime(locale.formats.r || '%I:%M:%S %p', d, locale); case 'r': return _strftime(locale.formats.r || '%I:%M:%S %p', d, locale);
case 'S': return pad(d.getSeconds()); case 'S': return pad(d.getSeconds());
case 's': return Math.floor((d.getTime() - msDelta) / 1000); case 's': return Math.floor((d.getTime() - msDelta) / 1000);
case 'T': return strftime(locale.formats.T || '%H:%M:%S', d, locale); case 'T': return _strftime(locale.formats.T || '%H:%M:%S', d, locale);
case 't': return '\t'; case 't': return '\t';
case 'u': case 'u':
var day = d.getDay(); var day = d.getDay();
return day == 0 ? 7 : day; // 1 - 7, Monday is first day of the week return day == 0 ? 7 : day; // 1 - 7, Monday is first day of the week
case 'v': return strftime(locale.formats.v || '%e-%b-%Y', d, locale); case 'v': return _strftime(locale.formats.v || '%e-%b-%Y', d, locale);
case 'w': return d.getDay(); // 0 - 6, Sunday is first day of the week case 'w': return d.getDay(); // 0 - 6, Sunday is first day of the week
case 'Y': return d.getFullYear(); case 'Y': return d.getFullYear();
case 'y': case 'y':