Skip to content
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)")
}
}
}