Follow-up on https://github.com/twentyhq/twenty/pull/9444/files - I had forgotten to include Date field types (in addition to DateTime)
24 lines
689 B
TypeScript
24 lines
689 B
TypeScript
import { DateFormat } from '@/localization/constants/DateFormat';
|
|
import { formatDateISOStringToDate } from '@/localization/utils/formatDateISOStringToDate';
|
|
import { formatDateISOStringToRelativeDate } from '@/localization/utils/formatDateISOStringToRelativeDate';
|
|
|
|
export const formatDateString = ({
|
|
value,
|
|
timeZone,
|
|
dateFormat,
|
|
displayAsRelativeDate,
|
|
}: {
|
|
timeZone: string;
|
|
dateFormat: DateFormat;
|
|
value?: string | null;
|
|
displayAsRelativeDate?: boolean;
|
|
}) => {
|
|
const formattedDate = value
|
|
? displayAsRelativeDate
|
|
? formatDateISOStringToRelativeDate(value)
|
|
: formatDateISOStringToDate(value, timeZone, dateFormat)
|
|
: '';
|
|
|
|
return formattedDate;
|
|
};
|