Skip to content

Commit fd74a7a

Browse files
committed
Removing checks for deleted timezones
Recent Linux distributions no longer carry some deprecated timezones. Removing them, or replacing with the equivalent timezone, according to the contents of `/usr/share/zoneinfo` across the years of Linux that we are currently supporting. Removed timezones include: - Israel -> Asia/Jerusalem - US/Pacific -> America/Los_Angeles - Brazil/East -> America/Sao_Paulo Unfortunately, the 'Europe/Kyiv'/'Europe/Kiev' timezone has changed around a bit in the past few years, likely as a result of political events. As a result, I don't think I have a single spelling that will work across all of the versions of OS's that we are trying to support. If we really want to ensure that the tests are testing that Foundation can load timezone information and not test the current political events, it would likely be a good idea to save a couple of timezone files off for testing purposes and use those across OS versions instead of hoping that the list of timezones doesn't change from year-to-year. For now, I'm going to point the test at London instead. The daylight savings time shifted on the same date in 2020, so there is no other change to the test needed.
1 parent 19e5eb0 commit fd74a7a

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

Darwin/Foundation-swiftoverlay-Tests/TestTimeZone.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class TestTimeZone : XCTestCase {
5252
func test_AnyHashableContainingTimeZone() {
5353
let values: [TimeZone] = [
5454
TimeZone(identifier: "America/Los_Angeles")!,
55-
TimeZone(identifier: "Europe/Kiev")!,
56-
TimeZone(identifier: "Europe/Kiev")!,
55+
TimeZone(identifier: "Europe/Kyiv")!,
56+
TimeZone(identifier: "Europe/Kyiv")!,
5757
]
5858
let anyHashables = values.map(AnyHashable.init)
5959
expectEqual(TimeZone.self, type(of: anyHashables[0].base))
@@ -66,8 +66,8 @@ class TestTimeZone : XCTestCase {
6666
func test_AnyHashableCreatedFromNSTimeZone() {
6767
let values: [NSTimeZone] = [
6868
NSTimeZone(name: "America/Los_Angeles")!,
69-
NSTimeZone(name: "Europe/Kiev")!,
70-
NSTimeZone(name: "Europe/Kiev")!,
69+
NSTimeZone(name: "Europe/Kyiv")!,
70+
NSTimeZone(name: "Europe/Kyiv")!,
7171
]
7272
let anyHashables = values.map(AnyHashable.init)
7373
expectEqual(TimeZone.self, type(of: anyHashables[0].base))

Tests/Foundation/Tests/TestCalendar.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class TestCalendar: XCTestCase {
270270

271271
func test_nextDate() throws {
272272
var calendar = Calendar.current
273-
calendar.timeZone = try XCTUnwrap(TimeZone(identifier: "US/Pacific"))
273+
calendar.timeZone = try XCTUnwrap(TimeZone(identifier: "America/Los_Angeles"))
274274
let date_20200101 = try XCTUnwrap(calendar.date(from: DateComponents(year: 2020, month: 01, day: 1)))
275275

276276
do {

Tests/Foundation/Tests/TestNSCalendar.swift

+7-4
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,11 @@ class TestNSCalendar: XCTestCase {
393393
try yield(to: block, (.chinese, "zh_CN", "Asia/Hong_Kong", "2015-04-02 07:13:22 +0800"))
394394
try yield(to: block, (.chinese, "zh_CN", "Asia/Hong_Kong", "2014-10-16 06:12:10 +0800"))
395395

396-
#if !os(Windows)
396+
#if !os(Windows) && !os(Linux)
397397
// TODO: these are deprecated aliases which are unavailable on Windows,
398398
// it is unclear if the support for the old names need to be validated.
399+
// TODO: these aliases have been removed from recent versions of Linux
400+
// as well
399401
try yield(to: block, (.hebrew, "he_IL", "Israel", "2018-12-24 05:40:43 +0200"))
400402
try yield(to: block, (.hebrew, "he_IL", "Israel", "2019-03-22 09:23:26 +0200"))
401403
#endif
@@ -505,8 +507,9 @@ class TestNSCalendar: XCTestCase {
505507
try yield(to: block, (.gregorian, "en_US", "America/Los_Angeles", "2013-03-26 10:04:16 -0700", "2013-03-26 00:00:00 -0700"))
506508
try yield(to: block, (.gregorian, "pt_BR", "America/Sao_Paulo", "2013-10-20 13:10:20 -0200", "2013-10-20 01:00:00 -0200")) // DST jump forward at midnight
507509
try yield(to: block, (.gregorian, "pt_BR", "America/Sao_Paulo", "2014-02-15 23:59:59 -0300", "2014-02-15 00:00:00 -0200")) // DST jump backward
508-
#if !os(Windows)
509-
// TODO: these are deprecated aliases which are unavailable on Windows,
510+
#if !os(Windows) && !os(Linux)
511+
// TODO: these are deprecated aliases which are unavailable on Windows
512+
// and updated Linux distributions,
510513
// it is unclear if the support for the old names need to be validated.
511514
try yield(to: block, (.gregorian, "pt_BR", "Brazil/East", "2013-10-20 13:10:20 -0200", "2013-10-20 01:00:00 -0200")) // DST jump forward at midnight
512515
try yield(to: block, (.gregorian, "pt_BR", "Brazil/East", "2014-02-15 23:59:59 -0300", "2014-02-15 00:00:00 -0200")) // DST jump backward
@@ -751,7 +754,7 @@ class TestNSCalendar: XCTestCase {
751754
try yield(to: block, (.islamic, "ar_SA", "Asia/Riyadh", "2015-05-29 00:00:00 +0300", "2015-05-31 00:00:00 +0300")) // islamic
752755
try yield(to: block, (.islamicCivil, "ar_SA", "Asia/Riyadh", "2015-05-29 00:00:00 +0300", "2015-05-31 00:00:00 +0300")) // islamic-civil
753756
try yield(to: block, (.chinese, "zh_CN", "Asia/Hong_Kong", "2015-01-03 00:00:00 +0800", "2015-01-05 00:00:00 +0800")) // chinese
754-
#if !os(Windows)
757+
#if !os(Windows) && !os(Linux)
755758
// TODO: these are deprecated aliases which are unavailable on Windows,
756759
// it is unclear if the support for the old names need to be validated.
757760
try yield(to: block, (.hebrew, "he_IL", "Israel", "2018-03-23 00:00:00 +0200", "2018-03-25 00:00:00 +0300")) // weekend with DST jump

Tests/Foundation/Tests/TestTimeZone.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ class TestTimeZone: XCTestCase {
257257
}
258258

259259
func test_isDaylightSavingTime() throws {
260-
let eukv = try XCTUnwrap(TimeZone(identifier: "Europe/Kiev"))
261-
260+
let eulon = try XCTUnwrap(TimeZone(identifier: "Europe/London"))
261+
262262
let dateNoDST = Date(timeIntervalSince1970: 1585432800.0) // March 29, 2020
263263
let dateDST = Date(timeIntervalSince1970: 1585515600.0) // March 30, 2020
264-
265-
XCTAssertFalse(eukv.isDaylightSavingTime(for: dateNoDST))
266-
XCTAssertTrue(eukv.isDaylightSavingTime(for: dateDST))
264+
265+
XCTAssertFalse(eulon.isDaylightSavingTime(for: dateNoDST))
266+
XCTAssertTrue(eulon.isDaylightSavingTime(for: dateDST))
267267
}
268268

269269
static var allTests: [(String, (TestTimeZone) -> () throws -> Void)] {

0 commit comments

Comments
 (0)