Skip to content

fix: measure a freshness age in UTC across a daylight-saving change - #21

Draft
jimy-r wants to merge 1 commit into
mainfrom
fix/freshness-age-in-utc
Draft

jimy-r wants to merge 1 commit into
mainfrom
fix/freshness-age-in-utc

Conversation

@jimy-r

@jimy-r jimy-r commented Oct 12, 2026

Copy link
Copy Markdown
Owner

What changed

A freshness age is now measured in UTC. With timezone set to a named zone, the log age and the artefact age were each the difference of two datetimes that share one tzinfo object. Python subtracts those by wall clock and ignores the offset each one carries, so an age that spanned a clock change was an hour out. Both ages now come from hours_between, which converts to UTC before it subtracts.

Why

Noon to noon read 24 hours on a fall-back night where 25 had passed, and 24 on a spring-forward night where 23 had. A job could stay FRESH an hour past its window or turn STALE an hour early. local, UTC and fixed offsets were never affected.

Tests

New tests cross an autumn clock change in America/New_York and a spring one in Australia/Sydney, for the log age and the artefact age, with a window set between the figure by wall clock and the real one. They skip on a host with no tz database. The suite passes locally, 184 tests.

Known limit: only the two age subtractions changed. Comparisons that add a timedelta to a zoned datetime still work by wall clock.

🤖 Generated with Claude Code

With `timezone` set to a named zone, the log age and the artefact age
were each the difference of two datetimes that share one tzinfo object.
Python subtracts those by wall clock and ignores the offset each one
carries, so an age that spans a clock change was an hour out: noon to
noon read 24 hours on a fall-back night where 25 had passed, and 24 on a
spring-forward night where 23 had. A job could stay FRESH an hour past
its window or turn STALE an hour early.

Both ages now come from `hours_between`, which converts to UTC before it
subtracts. `local`, `UTC` and fixed offsets were never affected.

Tests cross a fall-back change in America/New_York and a spring-forward
change in Australia/Sydney, for the log age and the artefact age, with a
window set between the wall-clock figure and the real one. They skip on
a host with no tz database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant