Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-8078] Some time zone identifiers are not supported by TimeZone type only on Linux #3670

Closed
swift-ci opened this issue Jun 22, 2018 · 2 comments
Assignees

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-8078
Radar None
Original Reporter guidomb (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Ubuntu 16.04 Swift 4.2 Snapshot 2018-06-21

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee @spevans
Priority Medium

md5: 97cf690688a2a5cb9c0ffeec6acfa0c9

Issue Description:

The following time zone identifiers which are returned by

TimeZone.knownTimeZoneIdentifiers

when used with

TimeZone.init?(idintifier:)

returns nil:

"America/Fort_Nelson",
"America/Punta_Arenas",
"Asia/Famagusta",
"Asia/Atyrau",
"Asia/Yangon",
"Europe/Kirov",
"Europe/Astrakhan",
"Europe/Saratov",
"Europe/Ulyanovsk",
"Asia/Barnaul",
"Asia/Tomsk"

To easily test this you can use the following code snippet

TimeZone.knownTimeZoneIdentifiers
    .map { ($0, TimeZone(identifier: $0)) }
    .filter { $0.1 == nil }
    .forEach { print("Ofender: \($0)") }

If you run on macOS nothing gets printed but if you run it on Ubuntu 16.04 you get the previous list of identifiers.

You can use https://hub.docker.com/r/guidomb/swift-snapshots/tags/ which I publish and use in my code.

@spevans
Copy link
Collaborator

spevans commented Jun 23, 2018

The timezone names get validated by calling the ICU function ucal_getCanonicalTimeZoneID (see https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/NumberDate.subproj/CFTimeZone.c#L1081)

which is rejecting 'America/Fort_Nelson' and the other names however I'm not sure why this these names are being rejected.

Note that CFTimeZoneCopyKnownNames() (used by knownTimeZoneIdentifiers) doesn't seem to validate that names hence why there are timezone that cannot be instantiated.

Probably needs two fixes:

1. Validate the names in CFTimeZoneCopyKnownNames()
2. Determine why ucal_getCanonicalTimeZoneID excludes those names, this could just be due to the ICU version being older on 16.04, which appears to be the case as the issue does not show up on Ubuntu18.04

@spevans
Copy link
Collaborator

spevans commented Jun 23, 2018

#1616

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants