diff --git a/src/app/shared/date.util.spec.ts b/src/app/shared/date.util.spec.ts index d7c418e8ae..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(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'); }); });