Skip to content

Conversation

@marcospri
Copy link
Contributor

@marcospri marcospri commented Jan 8, 2026

The previous approach relied on sampling from the current date back to a cutoff date using an arbitrary step (40 days)

That meant that depending on the time of year the process run it could hit different offsets for the same timezone, leading to inconsistent results.

The new approach uses pytz transition data directly which should be deterministic.


Found this after finding a change on the json files without any other apparent changes.

The new approach might be overkill, or at least the code is more verbose but I find "iterate over a TZ db" clearer than "step back in time 40 days at a time".


_get_latest_tz_names also uses the step back in time. If we merge a version of this I'll try to apply there too.

The previous approach relied on sampling from the current date
back to a cutoff date using an arbitrary step (40 days)

That meant that depending on the time of year the process run it could
hit different offsets for the same timezone, leading to inconsistent
results.

The new approach uses pytz transition data directly which should
be deterministic.
):
cutoff = datetime.datetime(self.RECENT_YEARS_START, 1, 1)

# Find the last transition before cutoff to get the offset active at cutoff
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this after finding an issue with pacific/norfolk

@marcospri marcospri marked this pull request as ready for review January 8, 2026 12:22
"Asia/Nicosia",
"Asia/Qatar",
"Asia/Riyadh",
"Asia/Tbilisi",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worked out a few differences in the data and it's down to these two. I can live with that.

@marcospri marcospri mentioned this pull request Jan 8, 2026
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.

2 participants