Skip to content

SR-8078: Some time zone identifiers are not supported by TimeZone on Linux #1616

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

Merged
merged 1 commit into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CoreFoundation/NumberDate.subproj/CFTimeZone.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ void CFTimeZoneSetDefault(CFTimeZoneRef tz) {
}

static CFDictionaryRef __CFTimeZoneCopyCompatibilityDictionary(void);
static Boolean __nameStringOK(CFStringRef name);

CFArrayRef CFTimeZoneCopyKnownNames(void) {
CFArrayRef tzs;
Expand All @@ -906,7 +907,7 @@ CFArrayRef CFTimeZoneCopyKnownNames(void) {
CFIndex idx;
for (idx = CFArrayGetCount(list); idx--; ) {
CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(list, idx);
if (CFDictionaryContainsKey(dict, item)) {
if (CFDictionaryContainsKey(dict, item) || !__nameStringOK(item)) {
CFArrayRemoveValueAtIndex(list, idx);
}
}
Expand Down
9 changes: 9 additions & 0 deletions TestFoundation/TestTimeZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TestTimeZone: XCTestCase {
// ("test_systemTimeZoneUsesSystemTime", test_systemTimeZoneUsesSystemTime),

("test_customMirror", test_tz_customMirror),
("test_knownTimeZones", test_knownTimeZones),
]
}

Expand Down Expand Up @@ -189,4 +190,12 @@ class TestTimeZone: XCTestCase {
XCTAssertNotNil(children["secondsFromGMT"])
XCTAssertNotNil(children["isDaylightSavingTime"])
}

func test_knownTimeZones() {
let timeZones = TimeZone.knownTimeZoneIdentifiers.sorted()
XCTAssertTrue(timeZones.count > 0, "No known timezones")
for tz in timeZones {
XCTAssertNotNil(TimeZone(identifier: tz), "Cant instantiate valid timeZone: \(tz)")
}
}
}