TimeZone initialization and validation improvements#95
Open
shial4 wants to merge 3 commits intoskiptools:mainfrom
Open
TimeZone initialization and validation improvements#95shial4 wants to merge 3 commits intoskiptools:mainfrom
shial4 wants to merge 3 commits intoskiptools:mainfrom
Conversation
…r nil handling, and populate abbreviationDictionary Co-authored-by: shial4 <8544773+shial4@users.noreply.github.com>
Fix TimeZone bugs: DST abbreviation, secondsFromGMT bounds/units, identifier nil handling, abbreviationDictionary
|
Thank you for your pull request and welcome to the Skip community. We require contributors to sign our contributor license agreement (CLA), and we don't seem to have the user(s) @Copilot on file. In order for us to review and merge your code, for each noted user please add your GitHub username to Skip's .clabot file |
marcprux
reviewed
Feb 21, 2026
| } | ||
|
|
||
| public static var abbreviationDictionary: [String : String] = [:] | ||
| public static var abbreviationDictionary: [String : String] = [ |
Member
There was a problem hiding this comment.
Rather than hardwiring this, could we build it dynamically by getting all the system TimeZone.getAvailableIDs() and then calling tz.getDisplayName(false, TimeZone.SHORT) on each of them?
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.
This pull request improves the robustness and correctness of the
TimeZoneimplementation inSkipFoundation, particularly around initialization and abbreviation handling. The changes ensure that invalid identifiers and abbreviations are handled gracefully, improve compatibility with Java's timezone APIs, and expand test coverage.TimeZone initialization and validation improvements:
TimeZone.init(identifier:)andTimeZone.init(abbreviation:)to detect and reject unknown or invalid identifiers and abbreviations, addressing a quirk where Java returns a default "GMT" timezone for unknown values.TimeZone.init(secondsFromGMT:)to validate the seconds offset (must be within ±18 hours) and construct the correct GMT identifier string, ensuring compatibility with Swift Foundation constraints.Abbreviation support and mapping:
TimeZone.abbreviationDictionarywith a comprehensive mapping of common timezone abbreviations to their canonical identifiers, enabling correct resolution of abbreviations.abbreviation(for:)to use the correct daylight saving flag when computing the abbreviation for a given date.Test improvements:
TestTimeZoneto cover invalid abbreviations, valid abbreviation mapping, and proper handling of unknown timezones, ensuring the new logic is exercised and validated. [1] [2]Thank you for contributing to the Skip project! Please use this space to describe your change and add any labels (bug, enhancement, documentation, etc.) to help categorize your contribution.Please review the contribution guide at https://skip.dev/docs/contributing/ for advice and guidance on making high-quality PRs.
Skip Pull Request Checklist:
swift testGenerated this PR summary
Used it to fix the core issue, I experienced and then use the for to validate issue do not persists anymore.
Added tests