From b50d512dee4077dfe68ff760e71ea722ceb6ea64 Mon Sep 17 00:00:00 2001 From: aryan-debug Date: Sun, 21 May 2023 22:14:09 -0700 Subject: [PATCH] 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');