Skip to content

Commit

Permalink
Merge pull request #68 from Kevin-Jin/patch-1
Browse files Browse the repository at this point in the history
Pass through unrecognized directives
  • Loading branch information
samsonjs authored Dec 27, 2016
2 parents 2294caa + f5bb098 commit b4e57a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions strftime.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@

// Examples for new Date(0) in GMT

// '%'
// case '%':
case 37:
resultString += '%';
break;

// 'Thursday'
// case 'A':
case 65:
Expand Down Expand Up @@ -499,6 +505,9 @@
break;

default:
if (isInScope) {
resultString += '%';
}
resultString += format[i];
break;
}
Expand Down
3 changes: 2 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ assert.format('%y', '11');
assert.format('%Z', null, 'GMT');
assert.format('%z', null, '+0000');
assert.format('%:z', null, '+00:00');
assert.format('%%', '%'); // any other char
assert.format('%%', '%'); // literal percent sign
assert.format('%g', '%g'); // unrecognized directive
assert.format('%F %T', null, '1970-01-01 00:00:00', new Date(0));
assert.format('%U', null, '12', new Date('2017-03-25 00:00:00 +0000'));
assert.format('%U', null, '13', new Date('2017-03-26 00:00:00 +0000'));
Expand Down

0 comments on commit b4e57a8

Please sign in to comment.