From 5c2c60db8b0e4757a2518b4c81c9cfe89c85e1bf Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Thu, 3 Nov 2022 15:08:16 +0100 Subject: [PATCH 1/2] [CST-7376] fix issue with timezone within the test class --- src/app/shared/date.util.spec.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/shared/date.util.spec.ts b/src/app/shared/date.util.spec.ts index d7c418e8ae..992a3f31fa 100644 --- a/src/app/shared/date.util.spec.ts +++ b/src/app/shared/date.util.spec.ts @@ -22,7 +22,7 @@ describe('Date Utils', () => { }); it('should convert NgbDateStruct to YYYY-MM-DDThh:mm:ssZ string', () => { // NOTE: month is zero indexed which is why it increases by one - const date = new Date(2022, 5, 3); + const date = new Date(Date.UTC(2022, 5, 3)) expect(dateToISOFormat(dateToNgbDateStruct(date))).toEqual('2022-06-03T00:00:00Z'); }); }); @@ -30,22 +30,22 @@ describe('Date Utils', () => { describe('dateToString', () => { it('should convert Date to YYYY-MM-DD string', () => { // NOTE: month is zero indexed which is why it increases by one - expect(dateToString(new Date(2022, 5, 3))).toEqual('2022-06-03'); + expect(dateToString(new Date(Date.UTC(2022, 5, 3)))).toEqual('2022-06-03'); }); it('should convert Date with time to YYYY-MM-DD string', () => { // NOTE: month is zero indexed which is why it increases by one - expect(dateToString(new Date(2022, 5, 3, 3, 24, 0))).toEqual('2022-06-03'); + expect(dateToString(new Date(Date.UTC(2022, 5, 3, 3, 24, 0)))).toEqual('2022-06-03'); }); it('should convert Month only to YYYY-MM-DD string', () => { // NOTE: month is zero indexed which is why it increases by one - expect(dateToString(new Date(2022, 5))).toEqual('2022-06-01'); + expect(dateToString(new Date(Date.UTC(2022, 5)))).toEqual('2022-06-01'); }); it('should convert ISO Date to YYYY-MM-DD string', () => { expect(dateToString(new Date('2022-06-03T03:24:00Z'))).toEqual('2022-06-03'); }); it('should convert NgbDateStruct to YYYY-MM-DD string', () => { // NOTE: month is zero indexed which is why it increases by one - const date = new Date(2022, 5, 3); + const date = new Date(Date.UTC(2022, 5, 3)); expect(dateToString(dateToNgbDateStruct(date))).toEqual('2022-06-03'); }); }); From da6da6209b2c362601620dd32b53951062ddc467 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Thu, 3 Nov 2022 15:46:36 +0100 Subject: [PATCH 2/2] [CST-7376] fix lint error --- src/app/shared/date.util.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/date.util.spec.ts b/src/app/shared/date.util.spec.ts index 992a3f31fa..4576ea497c 100644 --- a/src/app/shared/date.util.spec.ts +++ b/src/app/shared/date.util.spec.ts @@ -22,7 +22,7 @@ describe('Date Utils', () => { }); it('should convert NgbDateStruct to YYYY-MM-DDThh:mm:ssZ string', () => { // NOTE: month is zero indexed which is why it increases by one - const date = new Date(Date.UTC(2022, 5, 3)) + const date = new Date(Date.UTC(2022, 5, 3)); expect(dateToISOFormat(dateToNgbDateStruct(date))).toEqual('2022-06-03T00:00:00Z'); }); });