mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 06:06:10 +00:00
Merge remote-tracking branch 'origin/main' into fix/v1397-meta
This commit is contained in:
commit
383323b542
128 files changed
+1676
-256
No files matched your search
@@ -44,6 +44,7 @@ import { prefersReducedMotion } from "@/lib/charts/reduced-motion";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { CalendarDay, CervicalMucus, OvulationTest } from "./types";
|
||||
import { PHASE_HUE, OVULATION_HUE } from "./phase-tokens";
|
||||
import { shiftDateKey } from "@/lib/tz/format";
|
||||
|
||||
/** Trailing fallback window (days) when no MENSTRUAL-anchored cycle is active. */
|
||||
const FALLBACK_WINDOW_DAYS = 35;
|
||||
@@ -97,9 +98,7 @@ export function BbtChart({
|
||||
// recent temperatures.
|
||||
const fromDate = useMemo(() => {
|
||||
if (cycleStartDate) return cycleStartDate;
|
||||
const fallback = new Date(ymdToMs(today));
|
||||
fallback.setUTCDate(fallback.getUTCDate() - FALLBACK_WINDOW_DAYS);
|
||||
return fallback.toISOString().slice(0, 10);
|
||||
return shiftDateKey(today, -FALLBACK_WINDOW_DAYS);
|
||||
}, [cycleStartDate, today]);
|
||||
|
||||
const points = useMemo<BbtPoint[]>(() => {
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
DOCUMENT_LIST_MAX_LIMIT,
|
||||
type InboundDocumentDto,
|
||||
} from "@/lib/validations/inbound-documents";
|
||||
import { daysBetweenDateKeys } from "@/lib/tz/format";
|
||||
|
||||
/**
|
||||
* How many pages the picker walks. At the route's ceiling of 100 that is a
|
||||
@@ -38,8 +39,6 @@ import {
|
||||
*/
|
||||
const VAULT_PICKER_MAX_PAGES = 10;
|
||||
|
||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
/** The fields the option list reads off a document. */
|
||||
export type VaultDocument = Pick<
|
||||
InboundDocumentDto,
|
||||
@@ -82,10 +81,12 @@ export function isNearAnchor(
|
||||
anchorIso: string | null,
|
||||
): boolean {
|
||||
if (!documentDay || !anchorIso) return false;
|
||||
const day = Date.parse(`${documentDay.slice(0, 10)}T00:00:00.000Z`);
|
||||
const anchor = Date.parse(`${anchorIso.slice(0, 10)}T00:00:00.000Z`);
|
||||
if (Number.isNaN(day) || Number.isNaN(anchor)) return false;
|
||||
return Math.abs(day - anchor) <= ENCOUNTER_SUGGEST_WINDOW_DAYS * DAY_MS;
|
||||
const gap = daysBetweenDateKeys(
|
||||
anchorIso.slice(0, 10),
|
||||
documentDay.slice(0, 10),
|
||||
);
|
||||
if (Number.isNaN(gap)) return false;
|
||||
return Math.abs(gap) <= ENCOUNTER_SUGGEST_WINDOW_DAYS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -98,6 +98,11 @@ import {
|
||||
useMeasurementReminderMutations,
|
||||
type MeasurementReminder,
|
||||
} from "@/hooks/use-measurement-reminders";
|
||||
import {
|
||||
detectBrowserTimezone,
|
||||
shiftDateKey,
|
||||
userDayKey,
|
||||
} from "@/lib/tz/format";
|
||||
|
||||
// v1.18.1 (V3) — the active-measurement set, grouped so the dropdown
|
||||
// doesn't read as a flat 15-item list. Mirrors the Zod allow-list in
|
||||
@@ -177,8 +182,7 @@ function toDateInputValue(iso: string | null): string {
|
||||
if (!iso) return "";
|
||||
const d = new Date(iso);
|
||||
if (Number.isNaN(d.getTime())) return "";
|
||||
const offset = d.getTimezoneOffset();
|
||||
return new Date(d.getTime() - offset * 60 * 1000).toISOString().slice(0, 10);
|
||||
return userDayKey(d, detectBrowserTimezone());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -839,12 +843,11 @@ export function postponeOffsetTargets(
|
||||
// in between moves it an hour, which flips the date for anyone acting near
|
||||
// midnight. Anchoring today's local date at UTC noon and stepping whole
|
||||
// UTC days keeps every offset on the day its label names.
|
||||
const anchor = new Date(`${isoDayInTz(nowMs, tz)}T12:00:00.000Z`);
|
||||
return SNOOZE_CHIP_DAYS.map((days) => {
|
||||
const target = new Date(anchor);
|
||||
target.setUTCDate(target.getUTCDate() + days);
|
||||
return { days, date: target.toISOString().slice(0, 10) };
|
||||
});
|
||||
const today = isoDayInTz(nowMs, tz);
|
||||
return SNOOZE_CHIP_DAYS.map((days) => ({
|
||||
days,
|
||||
date: shiftDateKey(today, days),
|
||||
}));
|
||||
}
|
||||
|
||||
function intervalProgress(
|
||||
|
||||
@@ -66,6 +66,7 @@ export function DataPortabilityRow({
|
||||
intake: includeIntake ? "true" : "false",
|
||||
medicationId,
|
||||
}).toString();
|
||||
// eslint-disable-next-line healthlog/no-utc-day-key -- UTC by design: file name stamp, not a day shown or compared
|
||||
const stamp = new Date().toISOString().slice(0, 10);
|
||||
await downloadFromUrl(
|
||||
`/api/export/medications?${query}`,
|
||||
|
||||
@@ -30,6 +30,7 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { apiGet } from "@/lib/api/api-fetch";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
import type { LinkedDayContext } from "@/lib/mood/linked-context";
|
||||
import { userDayKey } from "@/lib/tz/format";
|
||||
|
||||
/**
|
||||
* The browser's own zone — the right answer for an entry that does not exist
|
||||
@@ -42,9 +43,7 @@ export function browserTimezone(): string {
|
||||
/** `YYYY-MM-DD` for a `datetime-local` value, or today when it is empty. */
|
||||
export function dayOfLocalInput(value: string): string {
|
||||
if (value.length >= 10) return value.slice(0, 10);
|
||||
const now = new Date();
|
||||
const local = new Date(now.getTime() - now.getTimezoneOffset() * 60 * 1000);
|
||||
return local.toISOString().slice(0, 10);
|
||||
return userDayKey(new Date(), browserTimezone());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ import type {
|
||||
HeightDraft,
|
||||
HeightUnitAdapter,
|
||||
} from "@/lib/profile/height-unit-display";
|
||||
import { detectBrowserTimezone, userDayKey } from "@/lib/tz/format";
|
||||
|
||||
/**
|
||||
* The four profile inputs of the onboarding baseline step.
|
||||
@@ -184,7 +185,7 @@ export function BaselineFields({
|
||||
id={IDS.dateOfBirth}
|
||||
value={value.dateOfBirth}
|
||||
onChange={(next) => onChange("dateOfBirth", next)}
|
||||
max={new Date().toISOString().slice(0, 10)}
|
||||
max={userDayKey(new Date(), detectBrowserTimezone())}
|
||||
autoComplete="bday"
|
||||
aria-invalid={errors.dateOfBirth ? true : undefined}
|
||||
aria-describedby={
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
|
||||
import type { AllergyDTO } from "@/lib/records/dto";
|
||||
import { dateOnlyAtNoonUtc, isCalendarDateKey } from "@/lib/tz/date-only";
|
||||
|
||||
const TEXT_MAX_LENGTH = 2000;
|
||||
/** Select sentinel for the optional "not assessed" severity. */
|
||||
@@ -41,11 +42,14 @@ interface AllergyFormProps {
|
||||
footerSlot?: HTMLElement | null;
|
||||
}
|
||||
|
||||
/** ISO date input (YYYY-MM-DD) → start-of-day UTC instant, or undefined. */
|
||||
/**
|
||||
* ISO date input (YYYY-MM-DD) → the instant a date-only value is stored at
|
||||
* (noon UTC), or undefined. UTC midnight read back as the previous day west
|
||||
* of UTC.
|
||||
*/
|
||||
function toInstant(value: string): string | undefined {
|
||||
if (!value) return undefined;
|
||||
const d = new Date(`${value}T00:00:00.000Z`);
|
||||
return Number.isNaN(d.getTime()) ? undefined : d.toISOString();
|
||||
if (!isCalendarDateKey(value)) return undefined;
|
||||
return dateOnlyAtNoonUtc(value).toISOString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* The environment settings default their date fields to today. "Today" is
|
||||
* the user's day: the UTC day was yesterday west of UTC in the evening and
|
||||
* tomorrow east of it in the small hours.
|
||||
*/
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
|
||||
const auth = vi.hoisted(() => ({ timezone: "America/Los_Angeles" }));
|
||||
vi.mock("@/hooks/use-auth", () => ({
|
||||
useAuth: () => ({
|
||||
user: { timezone: auth.timezone, modules: { environment: true } },
|
||||
isAuthenticated: true,
|
||||
}),
|
||||
}));
|
||||
vi.mock("next/navigation", () => ({
|
||||
useRouter: () => ({ push: vi.fn(), replace: vi.fn() }),
|
||||
usePathname: () => "/settings/environment",
|
||||
useSearchParams: () => new URLSearchParams(""),
|
||||
}));
|
||||
|
||||
import { EnvironmentSection } from "../environment-section";
|
||||
|
||||
function backfillEnd(): string | undefined {
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: 0 } } });
|
||||
const html = renderToStaticMarkup(
|
||||
<QueryClientProvider client={client}>
|
||||
<I18nProvider initialLocale="en">
|
||||
<EnvironmentSection />
|
||||
</I18nProvider>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
return /id="env-backfill-end"[^>]*value="([^"]*)"/.exec(html)?.[1];
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers({ toFake: ["Date"] });
|
||||
});
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
describe("<EnvironmentSection> date defaults", () => {
|
||||
it("defaults to the user's day west of UTC", () => {
|
||||
auth.timezone = "America/Los_Angeles";
|
||||
vi.setSystemTime(new Date("2026-07-03T03:00:00.000Z")); // 2 July, 20:00
|
||||
expect(backfillEnd()).toBe("2026-07-02");
|
||||
});
|
||||
|
||||
it("defaults to the user's day east of UTC", () => {
|
||||
auth.timezone = "Pacific/Kiritimati";
|
||||
vi.setSystemTime(new Date("2026-07-02T12:00:00.000Z")); // 3 July, 02:00
|
||||
expect(backfillEnd()).toBe("2026-07-03");
|
||||
});
|
||||
});
|
||||
@@ -33,7 +33,11 @@ import { TimeFormatSelect } from "@/components/settings/time-format-select";
|
||||
import { DateFormatSelect } from "@/components/settings/date-format-select";
|
||||
import { UnitPreferenceSelect } from "@/components/settings/unit-preference-select";
|
||||
import { GlucoseUnitSelect } from "@/components/settings/glucose-unit-select";
|
||||
import { detectBrowserTimezone, DEFAULT_TIMEZONE } from "@/lib/tz/format";
|
||||
import {
|
||||
detectBrowserTimezone,
|
||||
DEFAULT_TIMEZONE,
|
||||
userDayKey,
|
||||
} from "@/lib/tz/format";
|
||||
import { apiFetchRaw, apiGet } from "@/lib/api/api-fetch";
|
||||
import {
|
||||
recentProofErrorMessage,
|
||||
@@ -53,6 +57,7 @@ import {
|
||||
} from "./account-section-utils";
|
||||
import { AvatarSection } from "./avatar-section";
|
||||
import { SetupCard } from "./setup-card";
|
||||
import { dateOnlyKey } from "@/lib/tz/date-only";
|
||||
|
||||
export { resolveInitialTimezone } from "./account-section-utils";
|
||||
|
||||
@@ -145,7 +150,7 @@ export function AccountSection() {
|
||||
email: user.email ?? "",
|
||||
height: heightAdapter.toDraft(user.heightCm),
|
||||
dateOfBirth: user.dateOfBirth
|
||||
? new Date(user.dateOfBirth).toISOString().slice(0, 10)
|
||||
? dateOnlyKey(new Date(user.dateOfBirth))
|
||||
: "",
|
||||
gender: user.gender ?? "",
|
||||
timezone: resolveInitialTimezone(user.timezone, detectBrowserTimezone()),
|
||||
@@ -528,7 +533,7 @@ export function AccountSection() {
|
||||
setDateOfBirth(next);
|
||||
clearFieldError("dateOfBirth");
|
||||
}}
|
||||
max={new Date().toISOString().slice(0, 10)}
|
||||
max={userDayKey(new Date(), detectBrowserTimezone())}
|
||||
aria-invalid={fieldErrors.dateOfBirth ? true : undefined}
|
||||
aria-describedby={
|
||||
fieldErrors.dateOfBirth ? "dob-error" : undefined
|
||||
|
||||
@@ -32,6 +32,12 @@ import { formatDateTime } from "@/lib/format";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { apiDelete, apiGet, apiPost, apiPut } from "@/lib/api/api-fetch";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
import {
|
||||
DEFAULT_TIMEZONE,
|
||||
detectBrowserTimezone,
|
||||
userDayKey,
|
||||
validTimezoneOr,
|
||||
} from "@/lib/tz/format";
|
||||
|
||||
interface GeocodeResult {
|
||||
lat: number;
|
||||
@@ -72,14 +78,18 @@ interface EnvironmentOverview {
|
||||
attribution: string;
|
||||
}
|
||||
|
||||
function todayKey(): string {
|
||||
return new Date().toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
export function EnvironmentSection() {
|
||||
const { t, tCount } = useTranslations();
|
||||
const { user } = useAuth();
|
||||
const queryClient = useQueryClient();
|
||||
// Date defaults are the user's own days. The UTC day was tomorrow for
|
||||
// anyone east of UTC in the small hours and yesterday west of it in the
|
||||
// evening.
|
||||
const tz = validTimezoneOr(
|
||||
user?.timezone ?? detectBrowserTimezone(),
|
||||
DEFAULT_TIMEZONE,
|
||||
);
|
||||
const todayKey = () => userDayKey(new Date(), tz);
|
||||
|
||||
const enabled = user?.modules?.environment === true;
|
||||
|
||||
@@ -217,6 +227,9 @@ export function EnvironmentSection() {
|
||||
// user can still type an earlier start, but pre-home days resolve to SKIP on
|
||||
// the server — to fill the deep past they add an explicit location period.
|
||||
const effectiveBackfillStart =
|
||||
// `since` stays on the server's day for the home (a UTC day key in the
|
||||
// environment module), so the default start matches what the worker
|
||||
// compares against.
|
||||
backfillStart || home?.since?.slice(0, 10) || "";
|
||||
|
||||
return (
|
||||
|
||||
@@ -246,6 +246,7 @@ function CsvCard({
|
||||
since: since || undefined,
|
||||
until: until || undefined,
|
||||
});
|
||||
// eslint-disable-next-line healthlog/no-utc-day-key -- UTC by design: file name stamp, not a day shown or compared
|
||||
const stamp = new Date().toISOString().slice(0, 10);
|
||||
const filename = `${filenamePrefix}-${stamp}.csv`;
|
||||
await downloadFromUrl(`${endpoint}${query}`, filename);
|
||||
@@ -329,6 +330,7 @@ function MedicationsCsvCard() {
|
||||
until: until || undefined,
|
||||
intake: includeIntake ? "true" : "false",
|
||||
});
|
||||
// eslint-disable-next-line healthlog/no-utc-day-key -- UTC by design: file name stamp, not a day shown or compared
|
||||
const stamp = new Date().toISOString().slice(0, 10);
|
||||
await downloadFromUrl(
|
||||
`/api/export/medications${query}`,
|
||||
@@ -447,6 +449,7 @@ function FullBackupCard() {
|
||||
}
|
||||
|
||||
async function downloadOnce() {
|
||||
// eslint-disable-next-line healthlog/no-utc-day-key -- UTC by design: file name stamp, not a day shown or compared
|
||||
const stamp = new Date().toISOString().slice(0, 10);
|
||||
if (encrypt) {
|
||||
const res = await throwIfReproofRequired(
|
||||
|
||||
@@ -25,6 +25,7 @@ import { Button } from "@/components/ui/button";
|
||||
import { useEncounters } from "@/hooks/use-encounters";
|
||||
import { useFormatters, useTranslations } from "@/lib/i18n/context";
|
||||
import type { EncounterKind } from "@/generated/prisma/client";
|
||||
import { detectBrowserTimezone, userDayKey } from "@/lib/tz/format";
|
||||
|
||||
/**
|
||||
* How far ahead a booked visit is treated as the reason for this report.
|
||||
@@ -36,9 +37,7 @@ export const REPORT_VISIT_HORIZON_DAYS = 14;
|
||||
|
||||
/** The local `yyyy-MM-dd` a `DateField` takes, in the reader's own day. */
|
||||
function localDay(iso: string): string {
|
||||
const at = new Date(iso);
|
||||
const offset = at.getTimezoneOffset();
|
||||
return new Date(at.getTime() - offset * 60_000).toISOString().slice(0, 10);
|
||||
return userDayKey(new Date(iso), detectBrowserTimezone());
|
||||
}
|
||||
|
||||
export function ReportVisitOffer({
|
||||
|
||||
@@ -66,6 +66,13 @@ import { orderLeaves } from "@/lib/report-selection/selection";
|
||||
|
||||
import { ReportScopePicker } from "./report-scope-picker";
|
||||
import { ScopeSummary } from "./scope-summary";
|
||||
import { startOfLocalDayKey } from "@/lib/tz/local-day";
|
||||
import {
|
||||
DEFAULT_TIMEZONE,
|
||||
detectBrowserTimezone,
|
||||
shiftDateKey,
|
||||
validTimezoneOr,
|
||||
} from "@/lib/tz/format";
|
||||
|
||||
type ExportFormat = "pdf" | "fhir" | "package";
|
||||
|
||||
@@ -78,6 +85,12 @@ class ReportRequestError extends Error {}
|
||||
export function HealthRecordExportPanel() {
|
||||
const { t, locale } = useTranslations();
|
||||
const { user } = useAuth();
|
||||
// The report reads its window in the profile zone (the server's
|
||||
// `reportTz`), so the picked days are cut there too.
|
||||
const reportTz = validTimezoneOr(
|
||||
user?.timezone ?? detectBrowserTimezone(),
|
||||
DEFAULT_TIMEZONE,
|
||||
);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const [format, setFormat] = useState<ExportFormat>(
|
||||
@@ -155,8 +168,15 @@ export function HealthRecordExportPanel() {
|
||||
const range =
|
||||
customRange && startDate && endDate
|
||||
? {
|
||||
startDate: new Date(`${startDate}T00:00:00Z`).toISOString(),
|
||||
endDate: new Date(`${endDate}T23:59:59Z`).toISOString(),
|
||||
// The picked days are the user's days: from the first instant
|
||||
// of the first to the last instant of the last, in their zone.
|
||||
// UTC midnight started the window the previous evening west of
|
||||
// UTC, and the report read it as one day more.
|
||||
startDate: startOfLocalDayKey(startDate, reportTz).toISOString(),
|
||||
endDate: new Date(
|
||||
startOfLocalDayKey(shiftDateKey(endDate, 1), reportTz).getTime() -
|
||||
1,
|
||||
).toISOString(),
|
||||
}
|
||||
: { days };
|
||||
const res = await throwIfReproofRequired(
|
||||
@@ -190,6 +210,7 @@ export function HealthRecordExportPanel() {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
// eslint-disable-next-line healthlog/no-utc-day-key -- UTC by design: file name stamp, not a day shown or compared
|
||||
a.download = `healthlog-health-record-${new Date()
|
||||
.toISOString()
|
||||
.slice(0, 10)}.${ext}`;
|
||||
|
||||
@@ -22,12 +22,13 @@ import { toast } from "sonner";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { toastWrittenOutcome } from "@/components/outcome/outcome-toast";
|
||||
import { useFormatters, useTranslations } from "@/lib/i18n/context";
|
||||
import { useDateFormatPreference, useTranslations } from "@/lib/i18n/context";
|
||||
import {
|
||||
useLinkDocumentToVaccination,
|
||||
useVaccinationSuggestion,
|
||||
} from "./use-vaccinations";
|
||||
import type { VaccinationSuggestion } from "@/lib/vaccinations/document-suggestion";
|
||||
import { formatDate as formatCalendarDate } from "@/lib/date-format";
|
||||
|
||||
export function VaccinationDocumentSuggestion({
|
||||
anchor,
|
||||
@@ -39,8 +40,8 @@ export function VaccinationDocumentSuggestion({
|
||||
documentId: string;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslations();
|
||||
const format = useFormatters();
|
||||
const { t, locale } = useTranslations();
|
||||
const dateFormat = useDateFormatPreference();
|
||||
// Lift the date-only anchor to noon UTC — the rule is a ±7-day window, so the
|
||||
// time never changes the verdict, and noon keeps a viewer's local midnight
|
||||
// from rounding the day either way. The bare date would 422 the endpoint.
|
||||
@@ -60,7 +61,9 @@ export function VaccinationDocumentSuggestion({
|
||||
const name = candidate.antigenSlug
|
||||
? t(`vaccinations.catalog.${candidate.antigenSlug}`)
|
||||
: (candidate.vaccineName ?? t("vaccinations.suggestion.unnamed"));
|
||||
return `${name} · ${format.date(candidate.occurredAt)}`;
|
||||
// A date stored at UTC midnight: render the calendar date, not the
|
||||
// instant (the previous evening west of UTC).
|
||||
return `${name} · ${formatCalendarDate(candidate.occurredAt.slice(0, 10), dateFormat, locale)}`;
|
||||
};
|
||||
|
||||
const onPick = (candidate: VaccinationSuggestion) => {
|
||||
|
||||
@@ -35,6 +35,7 @@ import type { Practitioner } from "@/hooks/use-practitioners";
|
||||
import type { Vaccination, VaccinationWriteBody } from "./use-vaccinations";
|
||||
import { CatalogPicker } from "./catalog-picker";
|
||||
import { VaccinationDocumentPicker } from "./vaccination-document-picker";
|
||||
import { dayKeyAsUtcMidnight, isCalendarDateKey } from "@/lib/tz/date-only";
|
||||
|
||||
/** The seven anatomical sites, mirroring the Prisma `VaccinationSite` enum. */
|
||||
export const VACCINATION_SITES = [
|
||||
@@ -116,8 +117,10 @@ export function draftFromVaccination(row: Vaccination): VaccinationDraft {
|
||||
/** The day, at UTC midnight — an Impfpass carries dates, never times. */
|
||||
export function draftInstant(day: string): string | null {
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(day)) return null;
|
||||
const parsed = new Date(`${day}T00:00:00.000Z`);
|
||||
return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
|
||||
if (!isCalendarDateKey(day)) return null;
|
||||
// Stored at UTC midnight by the column's own convention; every reader
|
||||
// takes the date part.
|
||||
return dayKeyAsUtcMidnight(day).toISOString();
|
||||
}
|
||||
|
||||
/** Does the draft carry at least one identity arm? */
|
||||
|
||||
@@ -33,12 +33,17 @@ import { AlarmClock, Syringe } from "lucide-react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { InfoPopover } from "@/components/ui/info-popover";
|
||||
import { useFormatters, useTranslations } from "@/lib/i18n/context";
|
||||
import {
|
||||
useDateFormatPreference,
|
||||
useFormatters,
|
||||
useTranslations,
|
||||
} from "@/lib/i18n/context";
|
||||
import type { SeriesPosition } from "@/lib/vaccinations/series";
|
||||
import type { VaccinationRenewalDTO } from "@/lib/vaccinations/renewal";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { Vaccination } from "./use-vaccinations";
|
||||
import { CatalogInfo, catalogInfoAvailable } from "./catalog-info";
|
||||
import { formatDate as formatCalendarDate } from "@/lib/date-format";
|
||||
|
||||
type Translate = ReturnType<typeof useTranslations>["t"];
|
||||
|
||||
@@ -148,8 +153,8 @@ function DoseRow({
|
||||
row: GroupRow;
|
||||
onEdit?: (record: Vaccination) => void;
|
||||
}) {
|
||||
const { t } = useTranslations();
|
||||
const format = useFormatters();
|
||||
const { t, locale } = useTranslations();
|
||||
const dateFormat = useDateFormatPreference();
|
||||
const { record, position } = row;
|
||||
const series = seriesLabel(t, position);
|
||||
const identity = recordIdentity(t, record);
|
||||
@@ -198,7 +203,15 @@ function DoseRow({
|
||||
) : null}
|
||||
</div>
|
||||
<div className="text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs">
|
||||
<span>{format.date(record.occurredAt)}</span>
|
||||
<span>
|
||||
{/* A date, stored at UTC midnight: render the calendar date,
|
||||
not the instant (the previous evening west of UTC). */}
|
||||
{formatCalendarDate(
|
||||
record.occurredAt.slice(0, 10),
|
||||
dateFormat,
|
||||
locale,
|
||||
)}
|
||||
</span>
|
||||
{record.lotNumber ? (
|
||||
<span data-slot="vaccination-lot">
|
||||
{t("vaccinations.row.lot", { lot: record.lotNumber })}
|
||||
|
||||
Reference in new issue
Block a user