From a7d357547431c70704a2d5153c1f6c5b9728b81f Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Wed, 28 Oct 2026 20:03:17 +0000 Subject: [PATCH] Round the puppy's age in days instead of flooring it The days between two local midnights are an hour short of whole days once a spring DST switch falls between them, so flooring dropped a day from the age (and ticked weeks and months over a day late) until the autumn switch evened it out. --- src/app.js | 6 ++++-- src/changelog.json | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app.js b/src/app.js index 9ef4824..380a7de 100644 --- a/src/app.js +++ b/src/app.js @@ -281,7 +281,9 @@ const birth = startOfDay(new Date(y, mo - 1, d)); const ref = startOfDay(new Date(Number.isFinite(at) ? at : Date.now())); if (birth > ref) return null; - const days = Math.floor((ref - birth) / 86_400_000); + // Rounded, not floored: between local midnights a spring DST switch makes + // the span an hour short of whole days, and flooring would drop a day. + const days = Math.round((ref - birth) / 86_400_000); const weeks = Math.floor(days / 7); let months = (ref.getFullYear() - birth.getFullYear()) * 12 + (ref.getMonth() - birth.getMonth()); @@ -290,7 +292,7 @@ // Whole weeks left over after the calendar months (so "N months and M weeks"). const anchor = startOfDay(new Date(birth.getFullYear(), birth.getMonth() + months, birth.getDate())); - const remWeeks = Math.floor((ref - anchor) / 86_400_000 / 7); + const remWeeks = Math.floor(Math.round((ref - anchor) / 86_400_000) / 7); return { days, weeks, months, remWeeks }; } diff --git a/src/changelog.json b/src/changelog.json index 66d0b47..36168ba 100644 --- a/src/changelog.json +++ b/src/changelog.json @@ -1,4 +1,5 @@ [ + { "date": "2026-10-28", "text": "His age is no longer a day short for part of the year. Depending on when he was born, counting the days since his birthday could come up one short between the clocks going forward in spring and going back in autumn, and the week and month counts in “16 weeks (3 months and 3 weeks) old” ticked over a day late" }, { "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" },