mirror of
https://github.com/samsonjs/strftime.git
synced 2026-03-25 09:05:48 +00:00
fix %b format fall through, test new %j and %C specifiers
This commit is contained in:
parent
dae086e2cf
commit
4643912213
2 changed files with 4 additions and 2 deletions
|
|
@ -79,7 +79,7 @@
|
|||
case 'A': return locale.days[d.getDay()];
|
||||
case 'a': return locale.shortDays[d.getDay()];
|
||||
case 'B': return locale.months[d.getMonth()];
|
||||
case 'b': // fall through
|
||||
case 'b': return locale.shortMonths[d.getMonth()];
|
||||
case 'C':
|
||||
var y = String(d.getFullYear());
|
||||
return y.slice(0,2);
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
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 'j':
|
||||
case 'j':
|
||||
var y=new Date(d.getFullYear(), 0, 1);
|
||||
var day = Math.ceil((d.getTime() - y.getTime()) / (1000*60*60*24));
|
||||
return day;
|
||||
|
|
|
|||
|
|
@ -41,12 +41,14 @@ assert.format('%A', 'Tuesday')
|
|||
assert.format('%a', 'Tue')
|
||||
assert.format('%B', 'June')
|
||||
assert.format('%b', 'Jun')
|
||||
assert.format('%C', '20')
|
||||
assert.format('%D', '06/07/11')
|
||||
assert.format('%d', '07')
|
||||
assert.format('%e', '7')
|
||||
assert.format('%F', '2011-06-07')
|
||||
assert.format('%H', null, '18')
|
||||
assert.format('%I', null, '06')
|
||||
assert.format('%j', null, '158')
|
||||
assert.format('%k', null, '18')
|
||||
assert.format('%L', '067')
|
||||
assert.format('%l', null, ' 6')
|
||||
|
|
|
|||
Loading…
Reference in a new issue