Skip to content

Support POSIX TZ strings in TZif databases#15863

Merged
straight-shoota merged 5 commits intocrystal-lang:masterfrom
HertzDevil:feature/tzif-tz
Jun 15, 2025
Merged

Support POSIX TZ strings in TZif databases#15863
straight-shoota merged 5 commits intocrystal-lang:masterfrom
HertzDevil:feature/tzif-tz

Conversation

@HertzDevil
Copy link
Contributor

Follow-up to #15792.

@straight-shoota straight-shoota added this to the 1.17.0 milestone Jun 1, 2025
@HertzDevil
Copy link
Contributor Author

macOS CI is breaking because it explicitly sets $TZ to America/New_York, which means Time.local(9999, 12, 31, 23, 59, 59, nanosecond: 999_999_999) would return a UTC instant in the year 10000. It was originally introduced in #2682 for a spec of what is now HTTP.format_time, but that spec currently uses a fixed time zone and does not depend on $TZ anymore.

I propose unsetting $TZ in bin/ci.

@straight-shoota
Copy link
Member

straight-shoota commented Jun 2, 2025

Hm, I don't know. In general, it might not be a bad idea to set an explicit time zone other than UTC. Precisely to find problems with time zone expectations.

Why is this spec suddenly broken? Why is it impossible to have a Time instance for that instant in America/New_York?

@HertzDevil
Copy link
Contributor Author

Never mind, this is where the exception is actually raised:

crystal/src/time/tz.cr

Lines 112 to 114 in 96bf61e

local_new_year = Time.utc(local_year, 1, 1).to_unix + (new_year_is_dst ? dst_offset : std_offset)
local_new_year_next = Time.utc(local_year + 1, 1, 1).to_unix + (new_year_is_dst ? dst_offset : std_offset)
break if local_new_year <= unix_seconds < local_new_year_next

@straight-shoota straight-shoota removed this from the 1.17.0 milestone Jun 3, 2025
@straight-shoota straight-shoota added this to the 1.17.0 milestone Jun 13, 2025
@straight-shoota straight-shoota merged commit 4a6169b into crystal-lang:master Jun 15, 2025
37 checks passed
@HertzDevil HertzDevil deleted the feature/tzif-tz branch June 15, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants