Skip to content

Commit 8c87e9e

Browse files
authored
Use the default time zone instead of gmt, to match the previous behavior of ISO8601 calendar (#1229)
1 parent 0597595 commit 8c87e9e

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift

+2-5
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,22 @@ internal final class _CalendarGregorian: _CalendarProtocol, @unchecked Sendable
193193

194194
init(identifier: Calendar.Identifier, timeZone: TimeZone?, locale: Locale?, firstWeekday: Int?, minimumDaysInFirstWeek: Int?, gregorianStartDate: Date?) {
195195

196-
// ISO8601 has different default values for time zone, locale, firstWeekday, and minimumDaysInFirstWeek
197-
let defaultTimeZone: TimeZone
196+
// ISO8601 has different default values locale, firstWeekday, and minimumDaysInFirstWeek
198197
let defaultLocale: Locale?
199198
let defaultFirstWeekday: Int?
200199
let defaultMinimumDaysInFirstWeek: Int?
201200

202201
if identifier == .iso8601 {
203-
defaultTimeZone = .gmt
204202
defaultLocale = Locale.unlocalized
205203
defaultFirstWeekday = 2
206204
defaultMinimumDaysInFirstWeek = 4
207205
} else {
208-
defaultTimeZone = .default
209206
defaultLocale = nil
210207
defaultFirstWeekday = nil
211208
defaultMinimumDaysInFirstWeek = nil
212209
}
213210

214-
self.timeZone = timeZone ?? defaultTimeZone
211+
self.timeZone = timeZone ?? .default
215212
if let gregorianStartDate {
216213
self.gregorianStartDate = gregorianStartDate
217214
do {

Tests/FoundationEssentialsTests/GregorianCalendarTests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -3886,7 +3886,6 @@ final class GregorianCalendarTests : XCTestCase {
38863886

38873887
XCTAssertEqual(calendar1.firstWeekday, 2)
38883888
XCTAssertEqual(calendar1.minimumDaysInFirstWeek, 4)
3889-
XCTAssertEqual(calendar1.timeZone, .gmt)
38903889
XCTAssertEqual(calendar1.locale, .unlocalized)
38913890

38923891
// Verify that the properties are still mutable

0 commit comments

Comments
 (0)