Skip to content

Commit

Permalink
Removing checks for deleted timezones
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
etcwilde committed May 25, 2024
1 parent 19e5eb0 commit fd74a7a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Darwin/Foundation-swiftoverlay-Tests/TestTimeZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Tests/Foundation/Tests/TestCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 7 additions & 4 deletions Tests/Foundation/Tests/TestNSCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions Tests/Foundation/Tests/TestTimeZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)] {
Expand Down

0 comments on commit fd74a7a

Please sign in to comment.