New issue
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
Fixes for Date Manipulations #668
Conversation
date(byAdding:to:options:) was always trying to add the components to CFAbsoluteTime 0.0, rather than the passed-in date.
- DateComponent should only return isLeapMonth if the underlying leapMonthSet variable is true. Previously, DateComponent was setting isLeapMonth to false in situations where there is no concept of isLeapMonth. - _convert was using 'L' for isLeapMonth, when the corresponding UCalendarDateFields enum value for isLeapMonth is 'l'. This was causing _CFCalendarAddComponentsV to return error status.
@swift-ci Please smoke test |
@@ -89,6 +90,18 @@ class TestNSCalendar: XCTestCase { | |||
XCTAssertEqual(copy.firstWeekday, 2) | |||
XCTAssertEqual(copy.minimumDaysInFirstWeek, 2) | |||
} | |||
|
|||
func test_addingDates() { | |||
let calendar = Calendar.current |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the gregorian calendar specifically here, to avoid assuming anything about the environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in latest commit, thanks!
@swift-ci please test |
Thanks very much, @parkera and @lifeissweetgood, for quickly merging this PR. Do either of you know if this patch will make it into Swift 3.0.1 preview 2? Our team is in somewhat dire need of this patch, as it's preventing us from doing date manipulations on our Swift-based server. |
@UberJason Can you put up a PR against the |
Fixes for Date Manipulations
@parkera Done! |
This PR has fixes for DateComponents and Calendar which were causing date manipulations to fail, resolving SR-2846:
_convert()
is fixed for the character set for isLeapMonth to align with expected value fromUCalendarDateFields
('l' instead of 'L').date(byAdding:to:options:)
is fixed to do math on the passed-in date, rather than the reference time 0.0.A test for this is included.