@ -235,6 +235,63 @@ function validateAgainstMeta(parsedTree: any, errors = new Set(), typeErrors = n
} ,
} ,
typeErrors ,
typeErrors ,
)
)
} else if ( parsedTree . callee . name === 'DATETIME_DIFF' ) {
/ / p a r s e d T r e e . a r g u m e n t s [ 0 ] = d a t e
validateAgainstType (
parsedTree . arguments [ 0 ] ,
formulaTypes . DATE ,
( v : any ) => {
if ( ! validateDateWithUnknownFormat ( v ) ) {
typeErrors . add ( 'The first parameter of DATETIME_DIFF() should have date value' )
}
} ,
typeErrors ,
)
/ / p a r s e d T r e e . a r g u m e n t s [ 1 ] = d a t e
validateAgainstType (
parsedTree . arguments [ 1 ] ,
formulaTypes . DATE ,
( v : any ) => {
if ( ! validateDateWithUnknownFormat ( v ) ) {
typeErrors . add ( 'The second parameter of DATETIME_DIFF() should have date value' )
}
} ,
typeErrors ,
)
/ / p a r s e d T r e e . a r g u m e n t s [ 2 ] = [ " m i l l i s e c o n d s " | " m s " | " s e c o n d s " | " s " | " m i n u t e s " | " m " | " h o u r s " | " h " | " d a y s " | " d " | " w e e k s " | " w " | " m o n t h s " | " M " | " q u a r t e r s " | " Q " | " y e a r s " | " y " ]
validateAgainstType (
parsedTree . arguments [ 2 ] ,
formulaTypes . STRING ,
( v : any ) => {
if (
! [
'milliseconds' ,
'ms' ,
'seconds' ,
's' ,
'minutes' ,
'm' ,
'hours' ,
'h' ,
'days' ,
'd' ,
'weeks' ,
'w' ,
'months' ,
'M' ,
'quarters' ,
'Q' ,
'years' ,
'y' ,
] . includes ( v )
) {
typeErrors . add (
'The third parameter of DATETIME_DIFF() should have value either "milliseconds", "ms", "seconds", "s", "minutes", "m", "hours", "h", "days", "d", "weeks", "w", "months", "M", "quarters", "Q", "years", or "y"' ,
)
}
} ,
typeErrors ,
)
}
}
}
}
}
}