From d7418223fd2b7911b16bf7fa022f9c9d5c6e83b5 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sat, 5 Jan 2013 15:17:50 -0500 Subject: [PATCH] make %C pad the century, like C --- lib/index.js | 4 +--- test/test.js | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 5a5ab47..a0d915b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -77,9 +77,7 @@ case 'a': return locale.shortDays[d.getDay()]; case 'B': return locale.months[d.getMonth()]; case 'b': return locale.shortMonths[d.getMonth()]; - case 'C': - var y = String(d.getFullYear()); - return y.slice(0,2); + case 'C': return pad(Math.floor(d.getFullYear() / 100)); case 'D': return _strftime(locale.formats.D || '%m/%d/%y', d, locale); case 'd': return pad(d.getDate()); case 'e': return d.getDate(); diff --git a/test/test.js b/test/test.js index 079638f..ebe3a36 100644 --- a/test/test.js +++ b/test/test.js @@ -43,6 +43,7 @@ assert.format('%a', 'Tue') assert.format('%B', 'June') assert.format('%b', 'Jun') assert.format('%C', '20') +assert.format('%C', '01', null, new Date(100, 0, 1)) assert.format('%D', '06/07/11') assert.format('%d', '07') assert.format('%e', '7')