mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 08:12:52 +00:00
fix(dates): show the year whenever a date is not the current one
Sweeps every surface that renders a date from before this year without a year suffix — illness episodes/flares/day-logs, lab and custom-metric charts, the mood chart family, medication titration/side-effects/dose- history/next-dose captions (incl. the Dec→Jan rollover), cycle predictions and history, the BBT chart, the intraday-pulse day-nav, the date-range filter chip, and the nutrient/compliance charts. Each now routes through dateShortSmart / dateWithWeekdaySmart (format-locale.ts) or the matching date-format.ts helper, which add the year only when it differs from the current one — mirroring the workout list's existing model instead of a bare "19.02." that reads as this year's. Also fixes two sites that bypassed the app's locale entirely: the trusted-devices expiry (bare toLocaleDateString, host locale) and the admin token-name timestamp (hard-coded de-DE + Europe/Berlin) now both render through the user's own locale, hour-cycle, and timezone preference.
This commit is contained in:
1 parent
7f44e2fa37
commit
1ff179178f
28 files changed
+158
-104
No files matched your search
@@ -952,7 +952,7 @@ export function HealthChart({
|
||||
const allData: ChartDataPoint[] = Array.from(dailyAggregates.values())
|
||||
.map((bucket) => {
|
||||
const point: ChartDataPoint = {
|
||||
date: tzFmt.dateShort(new Date(bucket.timestamp)),
|
||||
date: tzFmt.dateShortSmart(new Date(bucket.timestamp)),
|
||||
timestamp: bucket.timestamp,
|
||||
};
|
||||
|
||||
@@ -1079,7 +1079,7 @@ export function HealthChart({
|
||||
).points.map<ChartDataPoint>((point) => {
|
||||
const date = new Date(point.timestamp);
|
||||
const out: ChartDataPoint = {
|
||||
date: tzFmt.dateShort(date),
|
||||
date: tzFmt.dateShortSmart(date),
|
||||
timestamp: point.timestamp,
|
||||
};
|
||||
for (const [type, value] of Object.entries(point.values)) {
|
||||
@@ -1209,7 +1209,7 @@ export function HealthChart({
|
||||
// Index shifted rows by the same day-key the chart already uses.
|
||||
const shiftedByDay = new Map<string, Record<string, number>>();
|
||||
for (const row of shifted) {
|
||||
const dayKey = tzFmt.dateShort(new Date(row.timestamp));
|
||||
const dayKey = tzFmt.dateShortSmart(new Date(row.timestamp));
|
||||
const slot = shiftedByDay.get(dayKey) ?? {};
|
||||
for (const [type, value] of Object.entries(row.values)) {
|
||||
if (typeof value === "number" && Number.isFinite(value)) {
|
||||
|
||||
@@ -284,7 +284,7 @@ export function MedicationComplianceChart({
|
||||
const chartData = useMemo(
|
||||
() =>
|
||||
data
|
||||
? aggregateMedicationCompliance(data, (d) => tzFmt.dateShort(d))
|
||||
? aggregateMedicationCompliance(data, (d) => tzFmt.dateShortSmart(d))
|
||||
: [],
|
||||
[data, tzFmt],
|
||||
);
|
||||
|
||||
@@ -400,7 +400,7 @@ export function MoodChart({
|
||||
|
||||
const allPoints: ChartDataPoint[] = data.entries
|
||||
.map((entry) => ({
|
||||
date: tzFmt.dateShort(new Date(dayKeyToTimestamp(entry.date))),
|
||||
date: tzFmt.dateShortSmart(new Date(dayKeyToTimestamp(entry.date))),
|
||||
timestamp: dayKeyToTimestamp(entry.date),
|
||||
pointIndex: 0,
|
||||
score: entry.score,
|
||||
@@ -436,7 +436,7 @@ export function MoodChart({
|
||||
})),
|
||||
{ bucket: bucketType },
|
||||
).points.map((point) => ({
|
||||
date: tzFmt.dateShort(new Date(point.timestamp)),
|
||||
date: tzFmt.dateShortSmart(new Date(point.timestamp)),
|
||||
timestamp: point.timestamp,
|
||||
pointIndex: 0,
|
||||
score: point.values.score,
|
||||
@@ -513,7 +513,7 @@ export function MoodChart({
|
||||
|
||||
const shiftedByDay = new Map<string, number>();
|
||||
for (const row of shifted) {
|
||||
const dayKey = tzFmt.dateShort(new Date(row.timestamp));
|
||||
const dayKey = tzFmt.dateShortSmart(new Date(row.timestamp));
|
||||
if (typeof row.score === "number" && Number.isFinite(row.score)) {
|
||||
shiftedByDay.set(dayKey, row.score);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
|
||||
import { CHART_HEIGHT_PX } from "@/lib/charts/constants";
|
||||
import { prefersReducedMotion } from "@/lib/charts/reduced-motion";
|
||||
import { formatDateShort } from "@/lib/format";
|
||||
import { useFormatters } from "@/lib/i18n/context";
|
||||
|
||||
import { RichChartTooltip, type RichTooltipRow } from "./chart-tooltip";
|
||||
|
||||
@@ -49,6 +49,7 @@ export function NutrientDailyBarChart({
|
||||
valueLabel,
|
||||
referenceValue,
|
||||
}: NutrientDailyBarChartProps) {
|
||||
const fmt = useFormatters();
|
||||
const points = useMemo(
|
||||
() => days.map((d) => ({ day: d.day, amount: Math.round(d.amount) })),
|
||||
[days],
|
||||
@@ -77,7 +78,7 @@ export function NutrientDailyBarChart({
|
||||
/>
|
||||
<XAxis
|
||||
dataKey="day"
|
||||
tickFormatter={(day: string) => formatDateShort(dayToDate(day))}
|
||||
tickFormatter={(day: string) => fmt.dateShortSmart(dayToDate(day))}
|
||||
tick={{ fontSize: 11, fill: "var(--muted-foreground)" }}
|
||||
stroke="var(--border)"
|
||||
minTickGap={24}
|
||||
@@ -116,7 +117,7 @@ export function NutrientDailyBarChart({
|
||||
return (
|
||||
<RichChartTooltip
|
||||
active
|
||||
label={formatDateShort(dayToDate(point.day))}
|
||||
label={fmt.dateShortSmart(dayToDate(point.day))}
|
||||
rows={rows}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user