Skip to content

TimeZone initialization and validation improvements#95

Open
shial4 wants to merge 3 commits intoskiptools:mainfrom
shial4:main
Open

TimeZone initialization and validation improvements#95
shial4 wants to merge 3 commits intoskiptools:mainfrom
shial4:main

Conversation

@shial4
Copy link
Contributor

@shial4 shial4 commented Feb 21, 2026

This pull request improves the robustness and correctness of the TimeZone implementation in SkipFoundation, 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:

  • Updated TimeZone.init(identifier:) and TimeZone.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.
  • Improved 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:

  • Populated TimeZone.abbreviationDictionary with a comprehensive mapping of common timezone abbreviations to their canonical identifiers, enabling correct resolution of abbreviations.
  • Fixed abbreviation(for:) to use the correct daylight saving flag when computing the abbreviation for a given date.

Test improvements:

  • Expanded and corrected tests in TestTimeZone to 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:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

Generated 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

Copilot AI and others added 3 commits February 21, 2026 03:49
…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
@cla-bot
Copy link

cla-bot bot commented Feb 21, 2026

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

}

public static var abbreviationDictionary: [String : String] = [:]
public static var abbreviationDictionary: [String : String] = [
Copy link
Member

Choose a reason for hiding this comment

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

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?

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.

3 participants