We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I noticed Date().add method returns incorrect date when daylight saving time changes between start and end dates. Test case:
func test_additionDuringDaylightSavingTimeChange() { let d_helsinki = Region(tz: TimeZoneName.europeHelsinki, cal: CalendarName.gregorian, loc: LocaleName.finnishFinland) Date.setDefaultRegion(d_helsinki) let date1 = try! DateInRegion(components: [.year: 2016, .month: 10, .day: 24], fromRegion: d_helsinki).absoluteDate // 2016-10-24 00:00:00 GMT+3 let date2 = try! DateInRegion(components: [.year: 2016, .month: 10, .day: 31], fromRegion: d_helsinki).absoluteDate // 2016-10-31 00:00:00 GMT+2 let date3 = date1.add(components: [Calendar.Component.weekOfYear: 1]) // 2016-10-30 23:00:00 GMT+2 let isDaylightSavingForDate1 = TimeZoneName.europeHelsinki.timeZone.isDaylightSavingTime(for: date1) let isDaylightSavingForDate2 = TimeZoneName.europeHelsinki.timeZone.isDaylightSavingTime(for: date2) XCTAssert(isDaylightSavingForDate1 != isDaylightSavingForDate2, "Daylight saving should change between dates") XCTAssert(date2 == date3, "Dates should be equal when adding a week in date") // Now dates are different by 1 hour }
I guess date2 and date3 should be equal and the date should be 2016-10-31 00:00:00 GMT+2.
The text was updated successfully, but these errors were encountered:
Fix bug malcommac#315: Date().add(components:) doesn't work when dayl…
0eb3e78
…ight saving time changes
See #316
Sorry, something went wrong.
Merge pull request #316 from jsslai/master
9185ba7
Fix bug #315: Date().add(components:) doesn't work when daylight savi…
No branches or pull requests
I noticed Date().add method returns incorrect date when daylight saving time changes between start and end dates. Test case:
I guess date2 and date3 should be equal and the date should be 2016-10-31 00:00:00 GMT+2.
The text was updated successfully, but these errors were encountered: