Repository navigation
Fix TimeZone initialization, exact offsets, and system abbreviation lookup - #95
Conversation
|
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] = [ |
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?
|
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 |
…ookup AI assistance: Copilot assisted the initial implementation; Codex revised the implementation, added regression tests, and verified Swift and Kotlin behavior. See PR skiptools#95 for validation details and existing suite failures.
…ookup AI assistance: Copilot assisted the initial implementation; Codex revised the implementation, added regression tests, and verified Swift and Kotlin behavior. See PR skiptools#95 for validation details and existing suite failures.
Unknown timezone identifiers currently fall back silently to GMT, abbreviation lookup has no default mappings, fixed offsets are passed to Java in the wrong units, and abbreviations always use the daylight-saving name. This PR fixes those behaviors in SkipFoundation. The relevant implementation remains unchanged in upstream main apart from its license header.
Changes
Locale.USso lookup keys do not depend on the device locale. Sort identifiers and retain the first match for deterministic collision handling. Ambiguous abbreviations can select a different region than Darwin Foundation; callers can override the dictionary.java.util.TimeZone.getAvailableIDs()for both known timezone lists and dictionary generation, matching the initializer's provider. Android'sjava.timeprovider advertises aliases such asACTthatjava.util.TimeZonerejects. Every advertised identifier must initialize successfully.SimpleTimeZone; round only the display identifier to the nearest minute. For example, a 61-second offset remains 61 seconds. Zero uses the identifierGMT, preserving date-formatting behavior.Tests and verification
Add six regression tests covering invalid identifiers and valid GMT aliases, exact positive/negative offsets and bounds, winter/summer abbreviations, system-derived abbreviations, custom dictionary overrides, and fixed-offset use by Calendar and DateFormatter. Enable the existing Skip offset and abbreviation tests, check that both known timezone lists agree, and retain the check that every advertised identifier initializes.
The system abbreviation test uses the names supplied by the platform for Adelaide and Kathmandu. Android can supply GMT-offset names where desktop Java returns
ACST/ACDT; the test verifies lookup of those names without assuming one timezone database's spelling. Integer-extreme rejection is tested on Skip because Darwin Foundation traps on those inputs.skip test --filter TestTimeZone --filter TestCalendar: passed, 58 Swift tests and 44 Kotlin/Robolectric tests, with 14 existing Kotlin skips.338a6e6(ACTand missingACST), then verified the fixes. TimeZone and Calendar pass: 44 Android tests, 14 existing skips; the same run passes 58 native Swift tests. TimeZone itself passes 18 Android tests with three existing skips.338a6e6passed Swift/Robolectric and connected iOS testing; Android API 28 failed on the two cases above. CI for9abf44breruns all checks, including API 28. Local emulator verification used API 33.swift test, including the Gradle harness, was executed. Eight native cases fail in DateTests, LocaleTests, TestDateFormatter, TestLengthFormatter, and TestNumberFormatter. Three Kotlin cases fail: BundleTests.testMainBundleInfo, TestDateComponents.testDateComponentsInitializationWithDate, and TestDateComponents.testDateComponentsWithSelectedComponents. All reproduce with the original PR's TimeZone implementation atd0b336d. The original implementation additionally fails Kotlin DateTests.testDateFormatting, which passes with this revision.git diff --check: passed.Local validation used Swift 6.4, Skip's Robolectric harness, and an Android API 33 emulator.
Contributor checklist
shial4is listed in the project's .clabot contributor list, andverification/cla-signedpasses for9abf44b.swift test; results and existing failures are recorded above.338a6e6; the latest CI rerun is linked above.The PR contains one squashed commit,
9abf44b, authored byshial4, with AI assistance disclosed above.