Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(calendar): group date-only upcoming events on the local calendar day
Gabriel Stein2ef397bcae4f
diff --git a/src/components/UpcomingMeetings.tsx b/src/components/UpcomingMeetings.tsxindex 2c2589812..d4973abf2 100644--- a/src/components/UpcomingMeetings.tsx+++ b/src/components/UpcomingMeetings.tsx@@ -9,6 +9,7 @@ import type { CalendarAttendee, CalendarEvent } from "../types/calendar";import { useSystemAudioPermission } from "../hooks/useSystemAudioPermission";import { canManageSystemAudioInApp } from "../utils/systemAudioAccess";import { getMeetingJoinUrl } from "../helpers/meetingJoinUrl";+import { parseEventDate } from "../utils/dateFormatting";interface UpcomingMeetingsProps {events: CalendarEvent[];@@ -52,7 +53,8 @@ function groupEventsByDay(events: CalendarEvent[], now: Date): DayGroup[] {const groups: DayGroup[] = [];const byKey = new Map<string, DayGroup>();for (const event of events) {- const date = new Date(event.start_time);+ const date = parseEventDate(event.start_time);+ if (!date) continue;const key = date.toDateString();let group = byKey.get(key);if (!group) {diff --git a/src/utils/dateFormatting.ts b/src/utils/dateFormatting.tsindex f8bc0cb2e..1140db1f2 100644--- a/src/utils/dateFormatting.ts+++ b/src/utils/dateFormatting.ts@@ -1,3 +1,16 @@+// Calendar events store all-day starts as date-only `YYYY-MM-DD` (Google's+// `start.date`). The ECMAScript parser reads that form as UTC midnight, which+// is still the previous local calendar day west of UTC, so date-only values+// must be parsed as local dates.+export function parseEventDate(value: string): Date | null {+ if (typeof value !== "string" || !value) return null;+ const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);+ const parsed = dateOnly+ ? new Date(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]))+ : new Date(value);+ return Number.isNaN(parsed.getTime()) ? null : parsed;+}+export function normalizeDbDate(dateStr: string): Date {const hasExplicitZone = /(?:Z|[+-]\d{2}:?\d{2})$/i.test(dateStr);const source = hasExplicitZone ? dateStr : `${dateStr}Z`;diff --git a/test/helpers/dateGroupFormatting.test.js b/test/helpers/dateGroupFormatting.test.jsindex dbb58a6c7..28be2e4c9 100644--- a/test/helpers/dateGroupFormatting.test.js+++ b/test/helpers/dateGroupFormatting.test.js@@ -61,6 +61,35 @@ test("string dates are accepted", async (t2) => {assert.equal(formatDateGroup(new Date(NOON_JUNE_15).toISOString(), t), "Today");});+test("date-only event starts parse as the local calendar day, not UTC midnight", async () => {+ const { parseEventDate } = await load();+ const previousTimezone = process.env.TZ;+ process.env.TZ = "America/Los_Angeles";++ try {+ // A UTC-midnight parse would land on June 14 in Los Angeles.+ const parsed = parseEventDate("2024-06-15");+ assert.equal(parsed.getFullYear(), 2024);+ assert.equal(parsed.getMonth(), 5);+ assert.equal(parsed.getDate(), 15);+ } finally {+ if (previousTimezone === undefined) delete process.env.TZ;+ else process.env.TZ = previousTimezone;+ }+});++test("timed event starts keep their instant and invalid values return null", async () => {+ const { parseEventDate } = await load();++ assert.equal(+ parseEventDate("2024-06-15T10:00:00-07:00").getTime(),+ Date.parse("2024-06-15T10:00:00-07:00")+ );+ assert.equal(parseEventDate("not-a-date"), null);+ assert.equal(parseEventDate(""), null);+ assert.equal(parseEventDate(null), null);+});+test("history groups zone-less SQLite timestamps as UTC near a local day boundary", async (t2) => {const { formatDateGroup } = await load();const previousTimezone = process.env.TZ;