File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed
packages/shared/src/utils/date Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -71,9 +71,9 @@ describe('formatDate', () => {
7171 expect ( DateTime . formatDate ( date , date_format , true ) ) . toEqual ( moment ( date ) . format ( date_format ) ) ;
7272 } ) ;
7373
74- it ( 'returns undefined when date is not null and should_format_null is false' , ( ) => {
74+ it ( 'returns formatted date when date is not null and should_format_null is false' , ( ) => {
7575 const date = moment ( '2023-09-20' ) . utc ( ) ;
76- expect ( DateTime . formatDate ( date , date_format , false ) ) . toBeUndefined ( ) ;
76+ expect ( DateTime . formatDate ( date , date_format , false ) ) . toEqual ( moment ( date ) . format ( date_format ) ) ;
7777 } ) ;
7878} ) ;
7979
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ export const toGMTFormat = (time?: moment.MomentInput) =>
7474 . format ( 'YYYY-MM-DD HH:mm:ss [GMT]' ) ;
7575
7676export const formatDate = ( date ?: moment . MomentInput , date_format = 'YYYY-MM-DD' , should_format_null = true ) =>
77- should_format_null && date !== null ? toMoment ( date ) . format ( date_format ) : undefined ;
77+ ! should_format_null && date === null ? undefined : toMoment ( date ) . format ( date_format ) ;
7878
7979export const formatTime = ( epoch : number | string , time_format = 'HH:mm:ss [GMT]' ) =>
8080 toMoment ( epoch ) . format ( time_format ) ;
You can’t perform that action at this time.
0 commit comments