@@ -20,6 +20,7 @@ export class CommonExpressionHelpers {
2020 allFieldValues : Record < string , any > = { } ;
2121 api = apiFunctions ;
2222 isEmpty = isValueEmpty ;
23+ dayjs = dayjs ;
2324
2425 constructor ( node : FormNode , patient : any , allFields : FormField [ ] , allFieldValues : Record < string , any > ) {
2526 this . allFields = allFields ;
@@ -101,7 +102,12 @@ export class CommonExpressionHelpers {
101102 * @returns true if left is before right
102103 */
103104 isDateBefore = ( left : Date , right : string | Date , format ?: string ) : boolean => {
104- const otherDate : Date = right instanceof Date ? right : ( format ? dayjs ( right , format , true ) . toDate ( ) : dayjs ( right , 'YYYY-MM-DD' , true ) . toDate ( ) ) ;
105+ const otherDate : Date =
106+ right instanceof Date
107+ ? right
108+ : format
109+ ? dayjs ( right , format , true ) . toDate ( )
110+ : dayjs ( right , 'YYYY-MM-DD' , true ) . toDate ( ) ;
105111 return left ?. getTime ( ) < otherDate . getTime ( ) ;
106112 } ;
107113
@@ -113,7 +119,12 @@ export class CommonExpressionHelpers {
113119 * @param timePeriod - The time unit: 'days', 'weeks', 'months', or 'years'
114120 * @returns true if selectedDate >= (baseDate + duration)
115121 */
116- isDateAfter = ( selectedDate : Date , baseDate : Date , duration : number , timePeriod : 'days' | 'weeks' | 'months' | 'years' ) : boolean => {
122+ isDateAfter = (
123+ selectedDate : Date ,
124+ baseDate : Date ,
125+ duration : number ,
126+ timePeriod : 'days' | 'weeks' | 'months' | 'years' ,
127+ ) : boolean => {
117128 const parsedBaseDate = dayjs ( baseDate ) ;
118129
119130 let calculatedDate : Date ;
@@ -165,7 +176,12 @@ export class CommonExpressionHelpers {
165176 * @returns true if left is after right
166177 */
167178 isDateAfterSimple = ( left : Date , right : string | Date , format ?: string ) : boolean => {
168- const otherDate : Date = right instanceof Date ? right : ( format ? dayjs ( right , format , true ) . toDate ( ) : dayjs ( right , 'YYYY-MM-DD' , true ) . toDate ( ) ) ;
179+ const otherDate : Date =
180+ right instanceof Date
181+ ? right
182+ : format
183+ ? dayjs ( right , format , true ) . toDate ( )
184+ : dayjs ( right , 'YYYY-MM-DD' , true ) . toDate ( ) ;
169185 return left ?. getTime ( ) > otherDate . getTime ( ) ;
170186 } ;
171187
0 commit comments