@@ -22,30 +22,30 @@ describe('Date Utils', () => {
2222 } ) ;
2323 it ( 'should convert NgbDateStruct to YYYY-MM-DDThh:mm:ssZ string' , ( ) => {
2424 // NOTE: month is zero indexed which is why it increases by one
25- const date = new Date ( 2022 , 5 , 3 ) ;
25+ const date = new Date ( Date . UTC ( 2022 , 5 , 3 ) ) ;
2626 expect ( dateToISOFormat ( dateToNgbDateStruct ( date ) ) ) . toEqual ( '2022-06-03T00:00:00Z' ) ;
2727 } ) ;
2828 } ) ;
2929
3030 describe ( 'dateToString' , ( ) => {
3131 it ( 'should convert Date to YYYY-MM-DD string' , ( ) => {
3232 // NOTE: month is zero indexed which is why it increases by one
33- expect ( dateToString ( new Date ( 2022 , 5 , 3 ) ) ) . toEqual ( '2022-06-03' ) ;
33+ expect ( dateToString ( new Date ( Date . UTC ( 2022 , 5 , 3 ) ) ) ) . toEqual ( '2022-06-03' ) ;
3434 } ) ;
3535 it ( 'should convert Date with time to YYYY-MM-DD string' , ( ) => {
3636 // NOTE: month is zero indexed which is why it increases by one
37- expect ( dateToString ( new Date ( 2022 , 5 , 3 , 3 , 24 , 0 ) ) ) . toEqual ( '2022-06-03' ) ;
37+ expect ( dateToString ( new Date ( Date . UTC ( 2022 , 5 , 3 , 3 , 24 , 0 ) ) ) ) . toEqual ( '2022-06-03' ) ;
3838 } ) ;
3939 it ( 'should convert Month only to YYYY-MM-DD string' , ( ) => {
4040 // NOTE: month is zero indexed which is why it increases by one
41- expect ( dateToString ( new Date ( 2022 , 5 ) ) ) . toEqual ( '2022-06-01' ) ;
41+ expect ( dateToString ( new Date ( Date . UTC ( 2022 , 5 ) ) ) ) . toEqual ( '2022-06-01' ) ;
4242 } ) ;
4343 it ( 'should convert ISO Date to YYYY-MM-DD string' , ( ) => {
4444 expect ( dateToString ( new Date ( '2022-06-03T03:24:00Z' ) ) ) . toEqual ( '2022-06-03' ) ;
4545 } ) ;
4646 it ( 'should convert NgbDateStruct to YYYY-MM-DD string' , ( ) => {
4747 // NOTE: month is zero indexed which is why it increases by one
48- const date = new Date ( 2022 , 5 , 3 ) ;
48+ const date = new Date ( Date . UTC ( 2022 , 5 , 3 ) ) ;
4949 expect ( dateToString ( dateToNgbDateStruct ( date ) ) ) . toEqual ( '2022-06-03' ) ;
5050 } ) ;
5151 } ) ;
0 commit comments