diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DateParserFormat.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DateParserFormat.ts new file mode 100644 index 0000000000000..a75f42564e8d7 --- /dev/null +++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DateParserFormat.ts @@ -0,0 +1 @@ +export const DATE_PARSER_FORMAT = 'MM/dd/yyyy'; diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DateTimeParserFormat.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DateTimeParserFormat.ts new file mode 100644 index 0000000000000..59fa44c42d300 --- /dev/null +++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/constants/DateTimeParserFormat.ts @@ -0,0 +1 @@ +export const DATE_TIME_PARSER_FORMAT = 'MM/dd/yyyy HH:mm'; diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/parseDateToString.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/parseDateToString.ts index 7f9a154f1110a..c8e1625e06221 100644 --- a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/parseDateToString.ts +++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/parseDateToString.ts @@ -1,3 +1,5 @@ +import { DATE_PARSER_FORMAT } from '@/ui/input/components/internal/date/constants/DateParserFormat'; +import { DATE_TIME_PARSER_FORMAT } from '@/ui/input/components/internal/date/constants/DateTimeParserFormat'; import { DateTime } from 'luxon'; type ParseDateToStringArgs = { @@ -11,7 +13,9 @@ export const parseDateToString = ({ isDateTimeInput, userTimezone, }: ParseDateToStringArgs) => { - const parsingFormat = isDateTimeInput ? 'MM/dd/yyyy HH:mm' : 'MM/dd/yyyy'; + const parsingFormat = isDateTimeInput + ? DATE_TIME_PARSER_FORMAT + : DATE_PARSER_FORMAT; const dateParsed = DateTime.fromJSDate(date, { zone: userTimezone }); diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/parseStringToDate.ts b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/parseStringToDate.ts index 4048313ed3ed9..b678aa3645c88 100644 --- a/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/parseStringToDate.ts +++ b/packages/twenty-front/src/modules/ui/input/components/internal/date/utils/parseStringToDate.ts @@ -1,3 +1,5 @@ +import { DATE_PARSER_FORMAT } from '@/ui/input/components/internal/date/constants/DateParserFormat'; +import { DATE_TIME_PARSER_FORMAT } from '@/ui/input/components/internal/date/constants/DateTimeParserFormat'; import { DateTime } from 'luxon'; type ParseStringToDateArgs = { @@ -11,7 +13,9 @@ export const parseStringToDate = ({ isDateTimeInput, userTimezone, }: ParseStringToDateArgs) => { - const parsingFormat = isDateTimeInput ? 'MM/dd/yyyy HH:mm' : 'MM/dd/yyyy'; + const parsingFormat = isDateTimeInput + ? DATE_TIME_PARSER_FORMAT + : DATE_PARSER_FORMAT; const parsedDate = isDateTimeInput ? DateTime.fromFormat(dateAsString, parsingFormat, { zone: userTimezone })