From e2369f3a3eba82ab8a9e198b5aab348e108b8218 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Wed, 28 Oct 2026 19:54:31 +0000 Subject: [PATCH] Place actogram bars by clock time so DST days fit the row On the day the clocks go back the day is 25 hours long, and bars were positioned by elapsed time over a fixed 24h, so everything after 3 am was drawn an hour late and the evening sleep ran past the row's end. Position bars and the now marker by wall-clock time instead. --- src/app.js | 22 +++++++++++++++++----- src/changelog.json | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/app.js b/src/app.js index a4b87f9..9ef4824 100644 --- a/src/app.js +++ b/src/app.js @@ -2829,8 +2829,17 @@ // Where "now" falls in the day, 0..1 — the shared x for the charts that run // midnight to midnight. function nowDayFraction() { - const now = new Date(); - return (now.getTime() - startOfDay(now).getTime()) / 86_400_000; + return clockDayFraction(Date.now()); + } + + // Wall-clock time of day as 0..1, read off the clock rather than counted + // from midnight, so a 23- or 25-hour day (the DST switches) still fits the + // 0h–24h axis: the hour that repeats in autumn is drawn over itself and the + // hour skipped in spring is just a gap. + function clockDayFraction(ts) { + const d = new Date(ts); + return (d.getHours() * 3_600_000 + d.getMinutes() * 60_000 + + d.getSeconds() * 1000 + d.getMilliseconds()) / 86_400_000; } // Vertical "now" rule for those charts: ink over a surface-coloured underlay @@ -2870,7 +2879,6 @@ const rowGap = N <= 31 ? 2 : N <= 90 ? 1 : 0; const H = MT + MB + N * rowH + (N - 1) * rowGap; svg.setAttribute("viewBox", `0 0 ${W} ${H}`); - const dayMs = 86_400_000; // Rows thinner than the text get a label only every so often — enough // rows apart that labels don't overlap — counted back from the last day. const labelEvery = Math.max(1, Math.ceil(11 / (rowH + rowGap))); @@ -2907,8 +2915,12 @@ const s = Math.max(wdw.start, dayStart); const e = Math.min(wdw.end, dayEnd); if (e <= s) continue; - const x = xOf((s - dayStart) / dayMs); - const wpx = ((e - s) / dayMs) * innerW; + // Placed by clock time, not elapsed time, so a DST day lines up with + // the hour gridlines; a window ending at the next midnight runs to 24h. + const fs = clockDayFraction(s); + const fe = e >= dayEnd ? 1 : clockDayFraction(e); + const x = xOf(fs); + const wpx = (fe - fs) * innerW; parts.push(``); } } diff --git a/src/changelog.json b/src/changelog.json index 2c2a037..66d0b47 100644 --- a/src/changelog.json +++ b/src/changelog.json @@ -1,4 +1,5 @@ [ + { "date": "2026-10-28", "text": "The When sleeping and When walking grids draw the days the clocks change correctly. On the Sunday the clocks go back the day is 25 hours long, and everything after 3 am was drawn an hour late — the evening sleep ran off the right-hand end of the row. In spring the 23-hour day stopped short of 24h instead. Each nap and walk now sits at the time the clock showed, lining up with the hour lines like every other day, and the “now” marker does the same on those days" }, { "date": "2026-10-03", "text": "The charts can cover any stretch of dates, not just the last 7, 14 or 30 days. Tap Custom on the “Charts cover” row and pick a from and a to date — up to a year at a time, and the to date can be in the past, so you can look back at, say, May on its own and see how much he slept or walked then. Every chart and panel that follows the 7 / 14 / 30 buttons follows the custom dates too, and their headings and trend sentences name the dates (“Over May 1 – Jun 15, daily sleep is down about 2h”). On a long range the daily bars sit edge to edge and the axis shows dates instead of weekdays, and the When sleeping and When walking grids use thinner rows so a few months still fit on the screen. The “average day” line on the Sleep trend and Walk trend is averaged over the custom dates as well. Tapping 7d, 14d or 30d goes back to the rolling window, and Custom remembers the dates you picked last" }, { "date": "2026-10-01", "text": "The app opens straight away when you have no connection. It used to check in with the server before showing anything, and on a weak signal or with the server out of reach that check could take a long while to give up, leaving a blank screen even though all your data was already on the phone. It now opens on the account you were last signed in to and checks in the background; if that sign-in has run out you are taken to the login screen as before" }, { "date": "2026-09-30", "text": "The Waking → pee and Meal → poo rows are gone from the Timing panel again. With a puppy who takes lots of short naps, most wake-ups were followed by another nap before any pee, so Waking → pee was built from a handful of odd cases and was hard to make sense of. The Pees, Poos and Meals rows are unchanged" },