Skip to content

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

♻️ Replace dayjs timezone conversion with Intl wall time helpers (#3410)

Luke Vellabeded461354a
diff --git a/CLAUDE.md b/CLAUDE.md
index bc033a0b1..8fa0b78bb 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -13,7 +13,7 @@ Rallly is a meeting scheduling application built with Next.js that allows users
- Better-Auth for authentication
- TailwindCSS for styling
- TypeScript throughout
-- `Intl` for all user-facing date and number formatting, wrapped in `lib/datetime/` (`format.ts`, `relative-time.tsx`, `duration.tsx`). dayjs is legacy: it survives only for calendar arithmetic and machine-format ISO strings in the poll options form, slot generator and CSV export. Never add a new dayjs import and never use it to render a date to a user
+- `Intl` for all user-facing date and number formatting, wrapped in `lib/datetime/` (`format.ts`, `relative-time.tsx`, `duration.tsx`). Converting between wall-clock times and instants goes through `wallTimeToInstant`/`instantToWallTime` in `lib/datetime/wall-time.ts`, which apply the time zone overrides. dayjs is legacy: it survives only for calendar arithmetic and machine-format ISO strings in the poll options form and CSV export, without its timezone plugin. Never add a new dayjs import and never use it to render a date to a user
- Base UI (`@base-ui/react`) for primitives in `packages/ui`. Radix was removed; never reintroduce it
## Development Commands
diff --git a/apps/web/biome.json b/apps/web/biome.json
index 1d6d52899..626e6cddf 100644
--- a/apps/web/biome.json
+++ b/apps/web/biome.json
@@ -538,9 +538,7 @@
"src/lib/datetime/**",
"src/features/poll/components/forms/poll-options-form/**",
"src/components/headless-date-picker.tsx",
- "src/**/edit-options/page.tsx",
"src/trpc/routers/polls.ts",
- "src/trpc/routers/index.ts",
"src/lib/utils/date-time-utils.ts",
"src/features/poll/components/manage-poll/use-csv-exporter.ts",
"src/test/setup.ts"
diff --git a/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/(edit)/edit-options/page.tsx b/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/(edit)/edit-options/page.tsx
index bdf1ee701..3bc5af376 100644
--- a/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/(edit)/edit-options/page.tsx
+++ b/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/(edit)/edit-options/page.tsx
@@ -14,29 +14,26 @@ import { usePoll } from "@/features/poll/components/poll-context";
import { filterParticipantsByVote } from "@/features/poll/utils";
import { useUser } from "@/features/user/client";
import { Trans, useTranslation } from "@/i18n/client";
-import { resolveTimeZone } from "@/lib/datetime/time-zone-overrides";
-import { dayjs } from "@/lib/dayjs";
+import {
+ addMinutesToWallTime,
+ instantToWallTime,
+} from "@/lib/datetime/wall-time";
import {
encodeDateOption,
getBrowserTimeZone,
} from "@/lib/utils/date-time-utils";
-const toPollWallTime = (
- value: ReturnType<typeof dayjs>,
- timeZone: string | null,
-) =>
- timeZone ? value.tz(resolveTimeZone(timeZone, value.toDate())) : value.utc();
+const toPollWallTime = (value: Date, timeZone: string | null) =>
+ instantToWallTime(value, timeZone ?? "UTC");
const convertOptionToString = (
option: { startTime: Date; duration: number },
timeZone: string | null,
) => {
- const start = toPollWallTime(dayjs(option.startTime), timeZone);
+ const start = toPollWallTime(option.startTime, timeZone);
return option.duration === 0
- ? start.format("YYYY-MM-DD")
- : `${start.format("YYYY-MM-DDTHH:mm:ss")}/${start
- .add(option.duration, "minute")
- .format("YYYY-MM-DDTHH:mm:ss")}`;
+ ? start.slice(0, 10)
+ : `${start}/${addMinutesToWallTime(start, option.duration)}`;
};
const Page = () => {
@@ -58,28 +55,26 @@ const Page = () => {
};
const firstDate = toPollWallTime(
- dayjs(poll.options[0]?.startTime),
+ poll.options[0]?.startTime ?? new Date(),
poll.timeZone,
);
const form = useForm({
defaultValues: {
- navigationDate: firstDate.format("YYYY-MM-DD"),
+ navigationDate: firstDate.slice(0, 10),
view: "month" as const,
options: poll.options.map((option) => {
- const start = toPollWallTime(dayjs(option.startTime), poll.timeZone);
+ const start = toPollWallTime(option.startTime, poll.timeZone);
return option.duration > 0
? {
type: "timeSlot" as const,
- start: start.format("YYYY-MM-DDTHH:mm:ss"),
+ start,
duration: option.duration,
- end: start
- .add(option.duration, "minute")
- .format("YYYY-MM-DDTHH:mm:ss"),
+ end: addMinutesToWallTime(start, option.duration),
}
: {
type: "date" as const,
- date: start.format("YYYY-MM-DD"),
+ date: start.slice(0, 10),
};
}),
timeZone: poll.timeZone ?? "",
diff --git a/apps/web/src/lib/datetime/slot-generator.ts b/apps/web/src/lib/datetime/slot-generator.ts
index c86b4ddab..0e2c1f000 100644
--- a/apps/web/src/lib/datetime/slot-generator.ts
+++ b/apps/web/src/lib/datetime/slot-generator.ts
@@ -1,5 +1,4 @@
-import { resolveTimeZoneAtWallTime } from "@/lib/datetime/time-zone-overrides";
-import { dayjs } from "@/lib/dayjs";
+import { wallTimeToInstant } from "@/lib/datetime/wall-time";
export type SlotGeneratorInput = {
startDate: string;
@@ -28,29 +27,15 @@ const hasTzOffset = (value: string) =>
const parseDateTimeInTimeZone = (value: string, timeZone?: string) =>
hasTzOffset(value)
- ? dayjs(value)
- : timeZone
- ? dayjs(value).tz(resolveTimeZoneAtWallTime(timeZone, value), true)
- : dayjs(value).utc(true);
-
-const parseLocalDateTimeInTimeZone = (
- date: string,
- time: string,
- timeZone: string | undefined,
-) =>
- timeZone
- ? dayjs(`${date}T${time}`).tz(
- resolveTimeZoneAtWallTime(timeZone, `${date}T${time}`),
- true,
- )
- : dayjs(`${date}T${time}`).utc(true);
+ ? new Date(value)
+ : wallTimeToInstant(value, timeZone ?? "UTC");
export const parseStartTime = (
startTime: string,
timeZone: string | undefined,
duration: number,
): TimeSlot => ({
- startTime: parseDateTimeInTimeZone(startTime, timeZone).toDate(),
+ startTime: parseDateTimeInTimeZone(startTime, timeZone),
duration,
});
@@ -58,6 +43,9 @@ export const parseStartTime = (
// without this a range like 1900-9999 would iterate millions of days.
export const MAX_SLOT_GENERATION_DAYS = 366;
+const MINUTE_MS = 60_000;
+const DAY_MS = 24 * 60 * MINUTE_MS;
+
export const generateTimeSlots = (
generator: SlotGeneratorInput,
timeZone: string | undefined,
@@ -75,45 +63,41 @@ export const generateTimeSlots = (
const allowed = new Set(generator.daysOfWeek.map((d) => dayMap[d]));
- // Use UTC for date iteration to avoid local timezone interference
- const startDay = dayjs.utc(generator.startDate).startOf("day");
- const endDay = dayjs.utc(generator.endDate).startOf("day");
+ // Iterate calendar dates as UTC midnights so no zone can shift them.
+ const startDay = Date.parse(generator.startDate.slice(0, 10));
+ const endDay = Date.parse(generator.endDate.slice(0, 10));
+ const zone = timeZone ?? "UTC";
const results: Array<TimeSlot> = [];
let daysVisited = 0;
- for (
- let cursor = startDay;
- cursor.isSameOrBefore(endDay, "day");
- cursor = cursor.add(1, "day")
- ) {
+ for (let cursor = startDay; cursor <= endDay; cursor += DAY_MS) {
if (daysVisited >= MAX_SLOT_GENERATION_DAYS) {
break;
}
daysVisited++;
- const date = cursor.format("YYYY-MM-DD");
+ const day = new Date(cursor);
+ const date = day.toISOString().slice(0, 10);
// The cursor's UTC date is the calendar date itself, so its weekday is
// the same in every zone.
- if (!allowed.has(cursor.day())) {
+ if (!allowed.has(day.getUTCDay())) {
continue;
}
- const windowStart = parseLocalDateTimeInTimeZone(
- date,
- generator.fromTime,
- timeZone,
- );
- const windowEnd = parseLocalDateTimeInTimeZone(
- date,
- generator.toTime,
- timeZone,
- );
- if (!windowEnd.isAfter(windowStart)) {
+ const windowStart = wallTimeToInstant(
+ `${date}T${generator.fromTime}`,
+ zone,
+ ).getTime();
+ const windowEnd = wallTimeToInstant(
+ `${date}T${generator.toTime}`,
+ zone,
+ ).getTime();
+ if (!(windowEnd > windowStart)) {
continue;
}
const duration = durationMinutes;
const interval = generator.interval ?? durationMinutes;
- const totalMinutes = windowEnd.diff(windowStart, "minute");
+ const totalMinutes = (windowEnd - windowStart) / MINUTE_MS;
// A non-positive (or NaN) interval would never advance the loop below.
if (!(duration > 0) || !(interval > 0)) {
@@ -125,9 +109,8 @@ export const generateTimeSlots = (
offset + duration <= totalMinutes;
offset += interval
) {
- const t = windowStart.add(offset, "minute");
results.push({
- startTime: t.toDate(),
+ startTime: new Date(windowStart + offset * MINUTE_MS),
duration,
});
}
diff --git a/apps/web/src/lib/datetime/wall-time.test.ts b/apps/web/src/lib/datetime/wall-time.test.ts
new file mode 100644
index 000000000..0818b39fa
--- /dev/null
+++ b/apps/web/src/lib/datetime/wall-time.test.ts
@@ -0,0 +1,125 @@
+import { describe, expect, it } from "vitest";
+import {
+ addMinutesToWallTime,
+ instantToWallTime,
+ wallTimeDiffInMinutes,
+ wallTimeToInstant,
+} from "./wall-time";
+
+describe("wallTimeToInstant", () => {
+ it("converts a wall time in a zone to an instant", () => {
+ expect(wallTimeToInstant("2025-01-15T09:00", "America/New_York")).toEqual(
+ new Date("2025-01-15T14:00:00Z"),
+ );
+ expect(
+ wallTimeToInstant("2025-07-15T09:00:00", "America/New_York"),
+ ).toEqual(new Date("2025-07-15T13:00:00Z"));
+ expect(wallTimeToInstant("2025-01-15T09:00:00", "Asia/Kolkata")).toEqual(
+ new Date("2025-01-15T03:30:00Z"),
+ );
+ });
+
+ it("treats UTC as the identity", () => {
+ expect(wallTimeToInstant("2025-01-15T09:00:00", "UTC")).toEqual(
+ new Date("2025-01-15T09:00:00Z"),
+ );
+ expect(wallTimeToInstant("2025-01-15", "UTC")).toEqual(
+ new Date("2025-01-15T00:00:00Z"),
+ );
+ });
+
+ it("accepts a space separator and fractional seconds", () => {
+ expect(
+ wallTimeToInstant("2025-01-15 09:00:30.5", "America/New_York"),
+ ).toEqual(new Date("2025-01-15T14:00:30.500Z"));
+ });
+
+ it("moves a time skipped by spring forward past the gap", () => {
+ expect(wallTimeToInstant("2025-03-09T02:30", "America/New_York")).toEqual(
+ new Date("2025-03-09T07:30:00Z"),
+ );
+ });
+
+ it("resolves a time repeated by fall back to its first occurrence", () => {
+ expect(wallTimeToInstant("2025-11-02T01:30", "America/New_York")).toEqual(
+ new Date("2025-11-02T05:30:00Z"),
+ );
+ });
+
+ it("applies the time zone overrides from the wall time", () => {
+ expect(wallTimeToInstant("2026-11-05T10:00", "America/Edmonton")).toEqual(
+ new Date("2026-11-05T16:00:00Z"),
+ );
+ expect(wallTimeToInstant("2026-11-05T10:00", "America/Winnipeg")).toEqual(
+ new Date("2026-11-05T15:00:00Z"),
+ );
+ expect(wallTimeToInstant("2026-11-05T10:00", "America/Vancouver")).toEqual(
+ new Date("2026-11-05T17:00:00Z"),
+ );
+ expect(wallTimeToInstant("2026-10-30T10:00", "America/Edmonton")).toEqual(
+ new Date("2026-10-30T16:00:00Z"),
+ );
+ });
+
+ it("returns an invalid date for unparseable input", () => {
+ expect(
+ Number.isNaN(wallTimeToInstant("garbage", "America/New_York").getTime()),
+ ).toBe(true);
+ });
+});
+
+describe("instantToWallTime", () => {
+ it("reads the clocks in a zone at an instant", () => {
+ expect(
+ instantToWallTime(new Date("2025-01-15T14:00:00Z"), "America/New_York"),
+ ).toBe("2025-01-15T09:00:00");
+ expect(
+ instantToWallTime(new Date("2025-01-15T03:30:00Z"), "Asia/Kolkata"),
+ ).toBe("2025-01-15T09:00:00");
+ expect(instantToWallTime(new Date("2025-01-15T00:00:00Z"), "UTC")).toBe(
+ "2025-01-15T00:00:00",
+ );
+ });
+
+ it("applies the time zone overrides from the instant", () => {
+ expect(
+ instantToWallTime(new Date("2026-11-05T16:00:00Z"), "America/Edmonton"),
+ ).toBe("2026-11-05T10:00:00");
+ expect(
+ instantToWallTime(new Date("2026-11-05T15:00:00Z"), "America/Winnipeg"),
+ ).toBe("2026-11-05T10:00:00");
+ expect(
+ instantToWallTime(new Date("2026-11-05T17:00:00Z"), "America/Vancouver"),
+ ).toBe("2026-11-05T10:00:00");
+ });
+
+ it("round trips with wallTimeToInstant", () => {
+ const wallTime = "2026-11-01T01:30:00";
+ for (const zone of [
+ "America/Edmonton",
+ "America/Winnipeg",
+ "America/Vancouver",
+ "Europe/London",
+ ]) {
+ expect(instantToWallTime(wallTimeToInstant(wallTime, zone), zone)).toBe(
+ wallTime,
+ );
+ }
+ });
+});
+
+describe("wallTimeDiffInMinutes", () => {
+ it("counts clock-face minutes", () => {
+ expect(
+ wallTimeDiffInMinutes("2025-03-09T01:00:00", "2025-03-09T04:00:00"),
+ ).toBe(180);
+ });
+});
+
+describe("addMinutesToWallTime", () => {
+ it("moves the clock face", () => {
+ expect(addMinutesToWallTime("2025-01-15T23:30:00", 60)).toBe(
+ "2025-01-16T00:30:00",
+ );
+ });
+});
diff --git a/apps/web/src/lib/datetime/wall-time.ts b/apps/web/src/lib/datetime/wall-time.ts
new file mode 100644
index 000000000..3b24748e8
--- /dev/null
+++ b/apps/web/src/lib/datetime/wall-time.ts
@@ -0,0 +1,117 @@
+import {
+ resolveTimeZone,
+ resolveTimeZoneAtWallTime,
+} from "@/lib/datetime/time-zone-overrides";
+
+const wallTimePattern =
+ /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/;
+
+/** Wall-clock fields encoded as if they were UTC, or NaN when unparseable. */
+const parseWallTime = (wallTime: string) => {
+ const match = wallTimePattern.exec(wallTime);
+ if (!match) {
+ return Number.NaN;
+ }
+ const [, year, month, day, hour = "0", minute = "0", second = "0", ms = "0"] =
+ match;
+ return Date.UTC(
+ Number(year),
+ Number(month) - 1,
+ Number(day),
+ Number(hour),
+ Number(minute),
+ Number(second),
+ Number(ms.padEnd(3, "0")),
+ );
+};
+
+const formatters = new Map<string, Intl.DateTimeFormat>();
+
+const getFormatter = (timeZone: string) => {
+ let formatter = formatters.get(timeZone);
+ if (!formatter) {
+ formatter = new Intl.DateTimeFormat("en-US", {
+ timeZone,
+ hourCycle: "h23",
+ year: "numeric",
+ month: "2-digit",
+ day: "2-digit",
+ hour: "2-digit",
+ minute: "2-digit",
+ second: "2-digit",
+ });
+ formatters.set(timeZone, formatter);
+ }
+ return formatter;
+};
+
+/** Wall-clock fields of `instant` in `timeZone`, encoded as if they were UTC. */
+const wallTimeAt = (instant: number, timeZone: string) => {
+ const parts = getFormatter(timeZone).formatToParts(instant);
+ const get = (type: Intl.DateTimeFormatPartTypes) =>
+ Number(parts.find((part) => part.type === type)?.value);
+ return (
+ Date.UTC(
+ get("year"),
+ get("month") - 1,
+ get("day"),
+ get("hour"),
+ get("minute"),
+ get("second"),
+ ) +
+ (((instant % 1000) + 1000) % 1000)
+ );
+};
+
+const offsetAt = (instant: number, timeZone: string) =>
+ wallTimeAt(instant, timeZone) - instant;
+
+const DAY_MS = 24 * 60 * 60 * 1000;
+
+/**
+ * The instant at which clocks in `timeZone` read `wallTime`
+ * (YYYY-MM-DD, optionally followed by THH:mm[:ss], with no offset).
+ *
+ * A time skipped by a forward transition resolves as if the clocks had not
+ * yet moved (02:30 on a spring-forward day becomes 03:30); a time repeated by
+ * a backward transition resolves to its first occurrence.
+ */
+export function wallTimeToInstant(wallTime: string, timeZone: string) {
+ const wall = parseWallTime(wallTime);
+ if (Number.isNaN(wall)) {
+ return new Date(Number.NaN);
+ }
+ const zone = resolveTimeZoneAtWallTime(timeZone, wallTime);
+ const offsetBefore = offsetAt(wall - DAY_MS, zone);
+ const offsetAfter = offsetAt(wall + DAY_MS, zone);
+ const candidates = [wall - offsetBefore, wall - offsetAfter].filter(
+ (instant) => wallTimeAt(instant, zone) === wall,
+ );
+ return new Date(
+ candidates.length > 0 ? Math.min(...candidates) : wall - offsetBefore,
+ );
+}
+
+/**
+ * What clocks in `timeZone` read at `instant`, as YYYY-MM-DDTHH:mm:ss with no
+ * offset.
+ */
+export function instantToWallTime(instant: Date, timeZone: string) {
+ const wall = wallTimeAt(
+ instant.getTime(),
+ resolveTimeZone(timeZone, instant),
+ );
+ return new Date(wall).toISOString().slice(0, 19);
+}
+
+/** Minutes from one wall-clock time to another, ignoring any zone. */
+export function wallTimeDiffInMinutes(from: string, to: string) {
+ return (parseWallTime(to) - parseWallTime(from)) / 60_000;
+}
+
+/** `wallTime` moved by `minutes` on the clock face, ignoring any zone. */
+export function addMinutesToWallTime(wallTime: string, minutes: number) {
+ return new Date(parseWallTime(wallTime) + minutes * 60_000)
+ .toISOString()
+ .slice(0, 19);
+}
diff --git a/apps/web/src/lib/dayjs.ts b/apps/web/src/lib/dayjs.ts
index 3c08cd76e..4cadb1c52 100644
--- a/apps/web/src/lib/dayjs.ts
+++ b/apps/web/src/lib/dayjs.ts
@@ -9,12 +9,10 @@ import localeData from "dayjs/plugin/localeData";
import localizedFormat from "dayjs/plugin/localizedFormat";
import minMax from "dayjs/plugin/minMax";
import relativeTime from "dayjs/plugin/relativeTime";
-import timezone from "dayjs/plugin/timezone";
import toArray from "dayjs/plugin/toArray";
import utc from "dayjs/plugin/utc";
dayjs.extend(utc);
-dayjs.extend(timezone);
dayjs.extend(advancedFormat);
dayjs.extend(calendar);
dayjs.extend(duration);
diff --git a/apps/web/src/lib/utils/date-time-utils.ts b/apps/web/src/lib/utils/date-time-utils.ts
index e0f06e72c..fba4307ef 100644
--- a/apps/web/src/lib/utils/date-time-utils.ts
+++ b/apps/web/src/lib/utils/date-time-utils.ts
@@ -5,7 +5,7 @@ import type {
import { dayjs } from "@/lib/dayjs";
export function getBrowserTimeZone() {
- return dayjs.tz.guess();
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
}
export const encodeDateOption = (option: DateTimeOption) => {
diff --git a/apps/web/src/trpc/routers/index.ts b/apps/web/src/trpc/routers/index.ts
index 16bd70e47..337315967 100644
--- a/apps/web/src/trpc/routers/index.ts
+++ b/apps/web/src/trpc/routers/index.ts
@@ -1,5 +1,3 @@
-import "@/lib/dayjs";
-
import { mergeRouters, router } from "../trpc";
import { auth } from "./auth";
import { billing } from "./billing";
diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.ts
index 8f39eccf5..2f4077897 100644
--- a/apps/web/src/trpc/routers/polls.ts
+++ b/apps/web/src/trpc/routers/polls.ts
@@ -40,8 +40,10 @@ import {
isSpaceBrandingActive,
} from "@/features/space/utils";
import { scheduleWebhookDispatch } from "@/features/webhook/mutations";
-import { resolveTimeZoneAtWallTime } from "@/lib/datetime/time-zone-overrides";
-import { dayjs } from "@/lib/dayjs";
+import {
+ wallTimeDiffInMinutes,
+ wallTimeToInstant,
+} from "@/lib/datetime/wall-time";
import { AppError } from "@/lib/errors/app-error";
import { identifyGroup, track } from "@/lib/posthog";
import { createIcsEvent } from "@/lib/utils/ics";
@@ -64,9 +66,9 @@ const collapseNewlines = (s: string) => s.replace(/\n{3,}/g, "\n\n");
// Mirrors the auto-close-polls house-keeping task: an option ends at
// start + duration, with all-day options (duration 0) treated as 24h.
const optionEndsInFuture = (option: { startTime: Date; duration: number }) =>
- dayjs(option.startTime)
- .add(option.duration === 0 ? 24 * 60 : option.duration, "minute")
- .isAfter(dayjs());
+ option.startTime.getTime() +
+ (option.duration === 0 ? 24 * 60 : option.duration) * 60_000 >
+ Date.now();
async function mintConferencing({
userId,
@@ -270,14 +272,12 @@ export const polls = router({
const timeZone = isTimePoll ? input.timeZone : null;
const optionsData = input.options.map((option) => ({
- startTime:
- timeZone && option.endDate
- ? dayjs(option.startDate)
- .tz(resolveTimeZoneAtWallTime(timeZone, option.startDate), true)
- .toDate()
- : dayjs(option.startDate).utc(true).toDate(),
+ startTime: wallTimeToInstant(
+ option.startDate,
+ timeZone && option.endDate ? timeZone : "UTC",
+ ),
duration: option.endDate
- ? dayjs(option.endDate).diff(dayjs(option.startDate), "minute")
+ ? wallTimeDiffInMinutes(option.startDate, option.endDate)
: 0,
}));
@@ -515,20 +515,13 @@ export const polls = router({
if (end) {
return {
- startTime: input.timeZone
- ? dayjs(start)
- .tz(
- resolveTimeZoneAtWallTime(input.timeZone, start),
- true,
- )
- .toDate()
- : dayjs(start).utc(true).toDate(),
- duration: dayjs(end).diff(dayjs(start), "minute"),
+ startTime: wallTimeToInstant(start, input.timeZone ?? "UTC"),
+ duration: wallTimeDiffInMinutes(start, end),
pollId,
};
} else {
return {
- startTime: dayjs(start).utc(true).toDate(),
+ startTime: wallTimeToInstant(start, "UTC"),
duration: 0,
pollId,
};
@@ -1004,9 +997,10 @@ export const polls = router({
start: res.scheduledEvent.start,
duration: res.scheduledEvent.allDay
? 0
- : dayjs(res.scheduledEvent.end).diff(
- dayjs(res.scheduledEvent.start),
- "minute",
+ : Math.trunc(
+ (res.scheduledEvent.end.getTime() -
+ res.scheduledEvent.start.getTime()) /
+ 60_000,
),
status: res.scheduledEvent.status,
}
@@ -1450,7 +1444,9 @@ export const polls = router({
event: "poll_schedule",
properties: {
attendee_count: attendees.length,
- days_since_created: dayjs().diff(poll.createdAt, "day"),
+ days_since_created: Math.trunc(
+ (Date.now() - poll.createdAt.getTime()) / 86_400_000,
+ ),
participant_count: poll.participants.length,
},
groups: {
diff --git a/biome-plugins/no-raw-datetime-formatting.grit b/biome-plugins/no-raw-datetime-formatting.grit
index 50f961fe9..b0f423fef 100644
--- a/biome-plugins/no-raw-datetime-formatting.grit
+++ b/biome-plugins/no-raw-datetime-formatting.grit
@@ -1,7 +1,7 @@
// Datetime formatting must go through lib/datetime so locale, timezone,
// and hour-cycle preferences are applied consistently (RAL-1244).
// The allowlist below is the escape hatch: lib/datetime itself, zone
-// detection (timezone-schema), zone abbreviations (timezone-utils), tests
+// detection (timezone-schema, date-time-utils), zone abbreviations (timezone-utils), tests
// (which format independently of the app to act as an oracle, matching the
// tests exemption in the biome.json overrides), repo scripts (tooling that
// renders no user-facing UI), and files still pending migration. Shrink it
@@ -22,6 +22,7 @@ or {
$filename <: not or {
r".*/src/lib/datetime/.*",
r".*/src/lib/utils/timezone-schema\.ts",
+ r".*/src/lib/utils/date-time-utils\.ts",
r".*/src/components/time-zone-picker/timezone-utils\.ts",
r".*/src/features/poll/components/manage-poll/use-csv-exporter\.ts",
r".*/tests/.*",
diff --git a/biome-plugins/no-unresolved-dayjs-tz.grit b/biome-plugins/no-unresolved-dayjs-tz.grit
deleted file mode 100644
index de2a7ab21..000000000
--- a/biome-plugins/no-unresolved-dayjs-tz.grit
+++ /dev/null
@@ -1,22 +0,0 @@
-// dayjs converts with the engine's own tz data, which lags recent rule
-// changes (Alberta, Manitoba, British Columbia in 2026). Route the zone
-// through `@/lib/datetime/time-zone-overrides` so server and browser agree.
-language js
-
-or {
- `$obj.tz($zone, $keepLocalTime)` as $match,
- `$obj.tz($zone)` as $match
-} where {
- $zone <: not or {
- `resolveTimeZone($zoneId, $instant)`,
- `resolveTimeZoneAtWallTime($zoneId, $wallTime)`
- },
- $filename <: not or {
- r".*\.test\.tsx?",
- r".*/tests/.*",
- r".*/scripts/.*",
- r".*/packages/.*",
- r".*/apps/landing/.*"
- },
- register_diagnostic(span=$match, message="Pass the zone through `resolveTimeZone` or `resolveTimeZoneAtWallTime` from `@/lib/datetime/time-zone-overrides` so recent rule changes apply on every engine.")
-}
diff --git a/biome.json b/biome.json
index c516c2fe3..64f4a003c 100644
--- a/biome.json
+++ b/biome.json
@@ -3,8 +3,7 @@
"root": true,
"plugins": [
"./biome-plugins/use-icon-button-label.grit",
- "./biome-plugins/no-raw-datetime-formatting.grit",
- "./biome-plugins/no-unresolved-dayjs-tz.grit"
+ "./biome-plugins/no-raw-datetime-formatting.grit"
],
"assist": {
"actions": {
diff --git a/packages/database/package.json b/packages/database/package.json
index e5c74a5ea..5132d43c9 100644
--- a/packages/database/package.json
+++ b/packages/database/package.json
@@ -18,7 +18,6 @@
"@prisma/adapter-pg": "^7.8.0",
"@prisma/client": "^7.8.0",
"@vercel/functions": "^3.3.6",
- "dayjs": "^1.11.13",
"pg": "^8.17.1"
},
"devDependencies": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 401392ef2..12490e6d8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -551,9 +551,6 @@ importers:
'@vercel/functions':
specifier: ^3.3.6
version: 3.4.1(@aws-sdk/[email protected])
- dayjs:
- specifier: ^1.11.13
- version: 1.11.19
pg:
specifier: ^8.17.1
version: 8.18.0