Skip to content

Commit d49cc96

Browse files
authored
Merge pull request #1568 from swiftlang/automerge/merge-main-2025-11-01_09-03
Merge `release/6.2` into `main`
2 parents 1cda636 + 7242fa9 commit d49cc96

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

Tests/FoundationInternationalizationTests/TimeZoneTests.swift

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,37 +59,41 @@ private struct TimeZoneTests {
5959
}
6060

6161
@Test func localizedName_103036605() {
62-
func test(_ tzIdentifier: String, _ localeIdentifier: String, _ style: TimeZone.NameStyle, _ expected: String?, sourceLocation: SourceLocation = #_sourceLocation) {
62+
func test(_ tzIdentifier: String, _ localeIdentifier: String, _ style: TimeZone.NameStyle, _ expected: String?, _ expectedDST: String?, sourceLocation: SourceLocation = #_sourceLocation) {
6363
let tz = TimeZone(identifier: tzIdentifier)
6464
guard let expected else {
6565
#expect(tz == nil, sourceLocation: sourceLocation)
6666
return
6767
}
6868

6969
let locale = Locale(identifier: localeIdentifier)
70-
#expect(tz?.localizedName(for: .generic, locale: locale) == expected, sourceLocation: sourceLocation)
70+
if let tz, tz.isDaylightSavingTime(for: .now) {
71+
#expect(tz.localizedName(for: style, locale: locale) == expectedDST, sourceLocation: sourceLocation)
72+
} else {
73+
#expect(tz?.localizedName(for: style, locale: locale) == expected, sourceLocation: sourceLocation)
74+
}
7175
}
7276

73-
test("America/Los_Angeles", "en_US", .generic, "Pacific Time")
74-
test("Europe/Berlin", "en_US", .generic, "Central European Time")
75-
test("Antarctica/Vostok", "en_US", .generic, "Vostok Time")
76-
test("Asia/Chongqing", "en_US", .generic, "China Standard Time")
77-
test("America/Sao_Paulo", "en_US", .generic, "Brasilia Standard Time")
77+
test("America/Los_Angeles", "en_US", .generic, "Pacific Time", "Pacific Time")
78+
test("Europe/Paris", "en_US", .generic, "Central European Time", "Central European Time")
79+
test("Antarctica/Vostok", "en_US", .generic, "Vostok Time", "Vostok Time")
80+
test("Asia/Chongqing", "en_US", .generic, "China Standard Time", "China Standard Time")
81+
test("America/Sao_Paulo", "en_US", .generic, "Brasilia Standard Time", "Brasilia Standard Time")
7882

79-
test("America/Los_Angeles", "zh_TW", .shortStandard, "太平洋時間")
80-
test("Europe/Berlin", "zh_TW", .shortStandard, "中歐時間")
81-
test("Antarctica/Vostok", "zh_TW", .shortStandard, "沃斯托克時間")
82-
test("Asia/Chongqing", "zh_TW", .shortStandard, "中國標準時間")
83-
test("America/Sao_Paulo", "zh_TW", .shortStandard, "巴西利亞標準時間")
83+
test("America/Los_Angeles", "zh_TW", .shortStandard, "PST", "PST")
84+
test("Europe/Paris", "zh_TW", .shortStandard, "GMT+1", "GMT+2")
85+
test("Antarctica/Davis", "zh_TW", .shortStandard, "GMT+7", "GMT+7")
86+
test("Asia/Chongqing", "zh_TW", .shortStandard, "GMT+8", "GMT+8")
87+
test("America/Sao_Paulo", "zh_TW", .shortStandard, "GMT-3", "GMT-3")
8488

8589
// abbreviation
86-
test("GMT", "en_US", .standard, "Greenwich Mean Time")
87-
test("GMT+8", "en_US", .standard, "GMT+08:00")
88-
test("PST", "en_US", .standard, "Pacific Time")
90+
test("GMT", "en_US", .standard, "Greenwich Mean Time", "Greenwich Mean Time")
91+
test("GMT+8", "en_US", .standard, "GMT+08:00", "GMT+08:00")
92+
test("PST", "en_US", .standard, "Pacific Standard Time", "Pacific Standard Time")
8993

9094
// invalid names
91-
test("XYZ", "en_US", .standard, nil)
92-
test("BOGUS/BOGUS", "en_US", .standard, nil)
95+
test("XYZ", "en_US", .standard, nil, nil)
96+
test("BOGUS/BOGUS", "en_US", .standard, nil, nil)
9397
}
9498

9599
@Test func timeZoneName_103097012() throws {

0 commit comments

Comments
 (0)