CFTimeZone: resolve GMT offset names - #136
Open
DTW-Thalion wants to merge 2 commits into
Open
Conversation
CFTimeZoneCreateWithName looked for a zone file for every name, so a GMT offset such as GMT+05:00 (which has no file) returned NULL. In particular a calendar whose time zone was created from a GMT offset could not be copied back, since CFCalendarCopyTimeZone recreates the zone from its name. Parse a GMT offset name and build the zone from the offset directly.
DTW-Thalion
force-pushed
the
fix/cftimezone-gmt-name
branch
from
July 24, 2026 15:22
5dd4b7f to
df61052
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CFTimeZoneCreateWithName looked for a zone file for every name, so a GMT offset such as GMT+05:00 or GMT-05:00, which has no file, returned NULL. This is why CFCalendarCopyTimeZone crashed callers for a calendar whose time zone came from a GMT offset: it recreates the zone from the stored name, got NULL back, and an unguarded caller then dereferenced it.
Parse a GMT offset name (GMT followed by a sign and the hours and minutes, with or without a colon) and build the zone from the offset directly, the same way CFTimeZoneCreateWithTimeIntervalFromGMT does. Plain named zones such as GMT and UTC still resolve through their zone files as before.
Tests/CFTimeZone/gmt.m checks the GMT, UTC and GMT-05:00 offsets and the CFCalendarCopyTimeZone round-trip, verified against Apple CoreFoundation.