From 51a6ade03d1fc992fc51e559eb8435563b3585ae Mon Sep 17 00:00:00 2001 From: aryan-debug Date: Mon, 17 Apr 2023 01:54:01 -0700 Subject: [PATCH 1/3] Fixed issue #84 --- strftime.js | 2 +- test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/strftime.js b/strftime.js index 84f5642..0dd38ca 100644 --- a/strftime.js +++ b/strftime.js @@ -649,7 +649,7 @@ // '70' // case 'y': case 121: - resultString += ('' + date.getFullYear()).slice(2); + resultString += ('' + date.getFullYear()).slice(padding === "" ? 3 : 2); break; // '+0000' diff --git a/test.js b/test.js index 16ae51e..981c5b9 100755 --- a/test.js +++ b/test.js @@ -100,6 +100,7 @@ assert.format('%k', null, '18'); assert.format('%L', '067'); assert.format('%l', null, ' 6'); assert.format('%-l', null, '6'); +assert.format("%-y", "1", null, new Date('2001-02-03T04:05:06')) assert.format('%_l', null, ' 6'); assert.format('%0l', null, '06'); assert.format('%M', null, '51'); From 6157e8a65081035c69f39b19c7ef68d2d67a267c Mon Sep 17 00:00:00 2001 From: aryan-debug Date: Sun, 21 May 2023 21:53:03 -0700 Subject: [PATCH 2/3] Fixed test case for %c --- test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.js b/test.js index 981c5b9..37bdff6 100755 --- a/test.js +++ b/test.js @@ -38,7 +38,7 @@ if (process.env.TZ == 'America/Vancouver') { testTimezone('America/Vancouver'); assert.format('%C', '01', '01', new Date(100, 0, 1)); assert.format('%X', '11:51:45 AM', '06:51:45 PM'); - assert.format('%c', 'Tue 07 Jun 2011 11:51:45 AM Pacific Daylight Time', 'Tue 07 Jun 2011 06:51:45 PM GMT'); + assert.format('%c', 'Tue 07 Jun 2011 11:51:45 AM Pacific Daylight Saving Time', 'Tue 07 Jun 2011 06:51:45 PM GMT'); assert.format('%j', '097', '098', new Date(1365390736236)); assert.format('%x', '06/07/11'); assert.format('%U', '12', null, new Date('2017-03-25 00:00:00 +0000')); From b50d512dee4077dfe68ff760e71ea722ceb6ea64 Mon Sep 17 00:00:00 2001 From: aryan-debug Date: Sun, 21 May 2023 22:14:09 -0700 Subject: [PATCH 3/3] Fixed issue #84 --- strftime.js | 3 ++- test.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/strftime.js b/strftime.js index 0dd38ca..6290de0 100644 --- a/strftime.js +++ b/strftime.js @@ -649,7 +649,8 @@ // '70' // case 'y': case 121: - resultString += ('' + date.getFullYear()).slice(padding === "" ? 3 : 2); + let year_without_century = ('' + date.getFullYear()).slice(2) + resultString += year_without_century.slice(padding === "" && year_without_century.charAt(0) === "0" ? 1 : 0); break; // '+0000' diff --git a/test.js b/test.js index 37bdff6..8c2d50c 100755 --- a/test.js +++ b/test.js @@ -101,6 +101,7 @@ assert.format('%L', '067'); assert.format('%l', null, ' 6'); assert.format('%-l', null, '6'); assert.format("%-y", "1", null, new Date('2001-02-03T04:05:06')) +assert.format("%-y", "23", null, new Date('2023-02-03T04:05:06')) assert.format('%_l', null, ' 6'); assert.format('%0l', null, '06'); assert.format('%M', null, '51');