From a2931c594ad69e82d181967ed78cabfabbd6ee5e Mon Sep 17 00:00:00 2001 From: Zongqi Chen Date: Mon, 9 Dec 2024 10:40:58 +0100 Subject: [PATCH] remove offset --- __tests__/unittest/date.test.js | 5 ----- lib/date.js | 15 +++++---------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/__tests__/unittest/date.test.js b/__tests__/unittest/date.test.js index 5494802..9c326a8 100644 --- a/__tests__/unittest/date.test.js +++ b/__tests__/unittest/date.test.js @@ -8,11 +8,6 @@ describe('date', () => { expect(lastUpdate).toMatch(RFC3339_REGEX); }); - it('tests getRFC3339Date without offset', () => { - const lastUpdate = getRFC3339Date(false); - expect(lastUpdate).toMatch(RFC3339_REGEX); - }); - it('test regex correctly', () => { let lastUpdate = "1985-04-12T23:20:50.52Z"; expect(lastUpdate).toMatch(RFC3339_REGEX); diff --git a/lib/date.js b/lib/date.js index a8e21c8..bc2874a 100644 --- a/lib/date.js +++ b/lib/date.js @@ -1,4 +1,4 @@ -function getRFC3339Date(includeOffset = true) { +function getRFC3339Date() { const now = new Date(); const year = now.getUTCFullYear(); const month = String(now.getUTCMonth() + 1).padStart(2, '0'); @@ -6,15 +6,10 @@ function getRFC3339Date(includeOffset = true) { const hours = String(now.getUTCHours()).padStart(2, '0'); const minutes = String(now.getUTCMinutes()).padStart(2, '0'); const seconds = String(now.getUTCSeconds()).padStart(2, '0'); - - if (includeOffset) { - const offsetHours = '01'; - const offsetMinutes = '00'; - const offsetSign = '+'; - return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${offsetSign}${offsetHours}:${offsetMinutes}`; - } else { - return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}Z`; - } + const offsetHours = '01'; + const offsetMinutes = '00'; + const offsetSign = '+'; + return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${offsetSign}${offsetHours}:${offsetMinutes}`; } module.exports = {