From fd74a7a8fdcaf2f5cafe53e39576ec14b7b52095 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Sat, 18 May 2024 22:52:41 -0700 Subject: [PATCH] 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. --- .../Foundation-swiftoverlay-Tests/TestTimeZone.swift | 8 ++++---- Tests/Foundation/Tests/TestCalendar.swift | 2 +- Tests/Foundation/Tests/TestNSCalendar.swift | 11 +++++++---- Tests/Foundation/Tests/TestTimeZone.swift | 10 +++++----- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Darwin/Foundation-swiftoverlay-Tests/TestTimeZone.swift b/Darwin/Foundation-swiftoverlay-Tests/TestTimeZone.swift index 09b769710e..4fe0f2bc7d 100644 --- a/Darwin/Foundation-swiftoverlay-Tests/TestTimeZone.swift +++ b/Darwin/Foundation-swiftoverlay-Tests/TestTimeZone.swift @@ -52,8 +52,8 @@ class TestTimeZone : XCTestCase { func test_AnyHashableContainingTimeZone() { let values: [TimeZone] = [ TimeZone(identifier: "America/Los_Angeles")!, - TimeZone(identifier: "Europe/Kiev")!, - TimeZone(identifier: "Europe/Kiev")!, + TimeZone(identifier: "Europe/Kyiv")!, + TimeZone(identifier: "Europe/Kyiv")!, ] let anyHashables = values.map(AnyHashable.init) expectEqual(TimeZone.self, type(of: anyHashables[0].base)) @@ -66,8 +66,8 @@ class TestTimeZone : XCTestCase { func test_AnyHashableCreatedFromNSTimeZone() { let values: [NSTimeZone] = [ NSTimeZone(name: "America/Los_Angeles")!, - NSTimeZone(name: "Europe/Kiev")!, - NSTimeZone(name: "Europe/Kiev")!, + NSTimeZone(name: "Europe/Kyiv")!, + NSTimeZone(name: "Europe/Kyiv")!, ] let anyHashables = values.map(AnyHashable.init) expectEqual(TimeZone.self, type(of: anyHashables[0].base)) diff --git a/Tests/Foundation/Tests/TestCalendar.swift b/Tests/Foundation/Tests/TestCalendar.swift index b0b512011d..0c86f9eee2 100644 --- a/Tests/Foundation/Tests/TestCalendar.swift +++ b/Tests/Foundation/Tests/TestCalendar.swift @@ -270,7 +270,7 @@ class TestCalendar: XCTestCase { func test_nextDate() throws { var calendar = Calendar.current - calendar.timeZone = try XCTUnwrap(TimeZone(identifier: "US/Pacific")) + calendar.timeZone = try XCTUnwrap(TimeZone(identifier: "America/Los_Angeles")) let date_20200101 = try XCTUnwrap(calendar.date(from: DateComponents(year: 2020, month: 01, day: 1))) do { diff --git a/Tests/Foundation/Tests/TestNSCalendar.swift b/Tests/Foundation/Tests/TestNSCalendar.swift index 8a223bed78..b4a71fa3a1 100644 --- a/Tests/Foundation/Tests/TestNSCalendar.swift +++ b/Tests/Foundation/Tests/TestNSCalendar.swift @@ -393,9 +393,11 @@ class TestNSCalendar: XCTestCase { try yield(to: block, (.chinese, "zh_CN", "Asia/Hong_Kong", "2015-04-02 07:13:22 +0800")) try yield(to: block, (.chinese, "zh_CN", "Asia/Hong_Kong", "2014-10-16 06:12:10 +0800")) -#if !os(Windows) +#if !os(Windows) && !os(Linux) // TODO: these are deprecated aliases which are unavailable on Windows, // it is unclear if the support for the old names need to be validated. + // TODO: these aliases have been removed from recent versions of Linux + // as well try yield(to: block, (.hebrew, "he_IL", "Israel", "2018-12-24 05:40:43 +0200")) try yield(to: block, (.hebrew, "he_IL", "Israel", "2019-03-22 09:23:26 +0200")) #endif @@ -505,8 +507,9 @@ class TestNSCalendar: XCTestCase { try yield(to: block, (.gregorian, "en_US", "America/Los_Angeles", "2013-03-26 10:04:16 -0700", "2013-03-26 00:00:00 -0700")) 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 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 -#if !os(Windows) - // TODO: these are deprecated aliases which are unavailable on Windows, +#if !os(Windows) && !os(Linux) + // TODO: these are deprecated aliases which are unavailable on Windows + // and updated Linux distributions, // it is unclear if the support for the old names need to be validated. 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 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 { try yield(to: block, (.islamic, "ar_SA", "Asia/Riyadh", "2015-05-29 00:00:00 +0300", "2015-05-31 00:00:00 +0300")) // islamic 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 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 -#if !os(Windows) +#if !os(Windows) && !os(Linux) // TODO: these are deprecated aliases which are unavailable on Windows, // it is unclear if the support for the old names need to be validated. 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 diff --git a/Tests/Foundation/Tests/TestTimeZone.swift b/Tests/Foundation/Tests/TestTimeZone.swift index 5e15c00026..c356cb4aaf 100644 --- a/Tests/Foundation/Tests/TestTimeZone.swift +++ b/Tests/Foundation/Tests/TestTimeZone.swift @@ -257,13 +257,13 @@ class TestTimeZone: XCTestCase { } func test_isDaylightSavingTime() throws { - let eukv = try XCTUnwrap(TimeZone(identifier: "Europe/Kiev")) - + let eulon = try XCTUnwrap(TimeZone(identifier: "Europe/London")) + let dateNoDST = Date(timeIntervalSince1970: 1585432800.0) // March 29, 2020 let dateDST = Date(timeIntervalSince1970: 1585515600.0) // March 30, 2020 - - XCTAssertFalse(eukv.isDaylightSavingTime(for: dateNoDST)) - XCTAssertTrue(eukv.isDaylightSavingTime(for: dateDST)) + + XCTAssertFalse(eulon.isDaylightSavingTime(for: dateNoDST)) + XCTAssertTrue(eulon.isDaylightSavingTime(for: dateDST)) } static var allTests: [(String, (TestTimeZone) -> () throws -> Void)] {