From 1ee97604bbc256787d9a98965060df92eeeba78d Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Wed, 8 Jun 2011 01:02:10 -0700 Subject: [PATCH] update recursive calls to strftime, fix indentation --- lib/index.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/index.js b/lib/index.js index 60fb24d..6318590 100644 --- a/lib/index.js +++ b/lib/index.js @@ -67,7 +67,7 @@ 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) { switch (c) { case 'A': return locale.days[d.getDay()]; @@ -75,10 +75,10 @@ case 'B': return locale.months[d.getMonth()]; case 'b': // fall through 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 '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 'I': return pad(hours12(d)); case 'k': return pad(d.getHours(), ' '); @@ -88,29 +88,29 @@ case 'm': return pad(d.getMonth() + 1); case 'n': return '\n'; 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 || '%I:%M:%S %p', 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 'S': return pad(d.getSeconds()); 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 'u': - var day = d.getDay(); - 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); + var day = d.getDay(); + 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 'w': return d.getDay(); // 0 - 6, Sunday is first day of the week case 'Y': return d.getFullYear(); case 'y': - var y = String(d.getFullYear()); - return y.slice(y.length - 2); + var y = String(d.getFullYear()); + return y.slice(y.length - 2); case 'Z': - if (_useUTC) { - return "GMT"; - } - else { - var tz = d.toString().match(/\((\w+)\)/); - return tz && tz[1] || ''; - } + if (_useUTC) { + return "GMT"; + } + else { + var tz = d.toString().match(/\((\w+)\)/); + return tz && tz[1] || ''; + } case 'z': if (_useUTC) { return "+0000";