Skip to content

Commit 2eb357a

Browse files
committed
minor(modeling-commons): support CalendarDate in api utils
1 parent 90c6f8b commit 2eb357a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/modeling-commons-frontend/app/utils/api-shared.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
export type DateInput = Date | string | number | null | undefined;
1+
import { CalendarDate } from "@internationalized/date";
2+
export type DateInput = CalendarDate | Date | string | number | null | undefined;
23
export function createApiDateString(value: DateInput): string | undefined {
34
if (value === null || value === undefined || value === "") {
45
return undefined;
56
}
67

8+
if (value instanceof CalendarDate) {
9+
return value.toString();
10+
}
11+
712
const date = typeof value === "string" || typeof value === "number" ? new Date(value) : value;
813

914
if (isNaN(date.getTime())) {

0 commit comments

Comments
 (0)