Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

♻️ Narrow DateInput to Date | number (#2533)

Luke Vella09dd1f72cc69
diff --git a/apps/web/src/components/forms/poll-options-form/month-calendar/time-picker.tsx b/apps/web/src/components/forms/poll-options-form/month-calendar/time-picker.tsx
index 64370d7e3..e5ac63286 100644
--- a/apps/web/src/components/forms/poll-options-form/month-calendar/time-picker.tsx
+++ b/apps/web/src/components/forms/poll-options-form/month-calendar/time-picker.tsx
@@ -30,7 +30,7 @@ const TimePicker: React.FunctionComponent<TimePickerProps> = ({
// The form works in naive local times, so options format in the system zone.
const formatTime = (time: string | Date) =>
- formatDateTime(time, { preset: "time", locale, timeFormat });
+ formatDateTime(new Date(time), { preset: "time", locale, timeFormat });
const getOptions = React.useCallback(() => {
if (!open) {
diff --git a/apps/web/src/lib/datetime/format.test.ts b/apps/web/src/lib/datetime/format.test.ts
index ac794ec07..5e535a7d1 100644
--- a/apps/web/src/lib/datetime/format.test.ts
+++ b/apps/web/src/lib/datetime/format.test.ts
@@ -123,13 +123,7 @@ describe("formatDateTime", () => {
expect(out).toContain("EDT");
});
- it("accepts ISO strings and timestamps", () => {
- expect(
- formatDateTime(at(13).toISOString(), {
- preset: "time",
- ...ctx("en", "hours24"),
- }),
- ).toBe("13:00");
+ it("accepts timestamps", () => {
expect(
formatDateTime(at(13).getTime(), {
preset: "time",
diff --git a/apps/web/src/lib/datetime/format.ts b/apps/web/src/lib/datetime/format.ts
index 91c95606f..941888570 100644
--- a/apps/web/src/lib/datetime/format.ts
+++ b/apps/web/src/lib/datetime/format.ts
@@ -1,6 +1,6 @@
import type { TimeFormat } from "@/lib/datetime/schema";
-export type DateInput = Date | string | number;
+export type DateInput = Date | number;
export type DatePreset =
| "date"