2022-03-15 13:30:45 +01:00
|
|
|
import { IConstraint } from 'interfaces/strategy';
|
2022-03-25 12:34:20 +01:00
|
|
|
import { formatDateYMDHMS } from 'utils/formatDate';
|
2022-03-15 13:30:45 +01:00
|
|
|
import { ILocationSettings } from 'hooks/useLocationSettings';
|
2022-04-07 10:31:06 +02:00
|
|
|
import { CURRENT_TIME_CONTEXT_FIELD } from 'utils/operatorsForContext';
|
2022-03-15 13:30:45 +01:00
|
|
|
|
|
|
|
export const formatConstraintValue = (
|
|
|
|
constraint: IConstraint,
|
|
|
|
locationSettings: ILocationSettings
|
|
|
|
): string | undefined => {
|
|
|
|
if (
|
|
|
|
constraint.value &&
|
|
|
|
constraint.contextName === CURRENT_TIME_CONTEXT_FIELD
|
|
|
|
) {
|
|
|
|
return formatDateYMDHMS(constraint.value, locationSettings.locale);
|
|
|
|
}
|
|
|
|
|
|
|
|
return constraint.value;
|
|
|
|
};
|