mirror of
https://github.com/samsonjs/strftime.git
synced 2026-03-25 09:05:48 +00:00
update recursive calls to strftime, fix indentation
This commit is contained in:
parent
70445ffc9a
commit
1ee97604bb
1 changed files with 18 additions and 18 deletions
36
lib/index.js
36
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";
|
||||
|
|
|
|||
Loading…
Reference in a new issue