From 546b1b667810b647fbdaf3eb2d3a65662ca4d7c0 Mon Sep 17 00:00:00 2001 From: Yashua Date: Fri, 27 Dec 2013 17:14:16 -0700 Subject: [PATCH 1/2] Update dateformatter.js Corrected date calculation for day of week --- lib/dateformatter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dateformatter.js b/lib/dateformatter.js index f07e34d7..00c02134 100644 --- a/lib/dateformatter.js +++ b/lib/dateformatter.js @@ -68,7 +68,7 @@ exports.l = function (input) { }; exports.N = function (input) { var d = input.getDay(); - return (d >= 1) ? d + 1 : 7; + return (d >= 1) ? d : 7; }; exports.S = function (input) { var d = input.getDate(); From 2de7bd6fca96ec8620fa6690210261ab2582c7f5 Mon Sep 17 00:00:00 2001 From: Yashua Date: Sat, 28 Dec 2013 09:45:53 -0700 Subject: [PATCH 2/2] Added/modified day of week tests This matches PHP: echo date('N', strtotime('2011-09-06T16:05:02.000Z'))."\n"; echo date('N', strtotime('2011-09-04T16:05:02.000Z'))."\n"; --- tests/filters.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/filters.test.js b/tests/filters.test.js index 89504fb2..c793002b 100644 --- a/tests/filters.test.js +++ b/tests/filters.test.js @@ -41,7 +41,8 @@ var n = new Swig(), { c: 'v|date("D")', v: d, e: 'Tue' }, { c: 'v|date("j")', v: d, e: '6' }, { c: 'v|date("l")', v: d, e: 'Tuesday' }, - { c: 'v|date("N")', v: d, e: '3' }, + { c: 'v|date("N")', v: d, e: '2' }, + { c: 'v|date("N")', v: makeDate(420, 2011, 8, 4), e: '7'}, { c: 'v|date("S")', v: d, e: 'th' }, { c: 'v|date("w")', v: d, e: '2' }, { c: 'v|date("z")', v: d, e: '248' },