-
Notifications
You must be signed in to change notification settings - Fork 8
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
Implement Date Component Differences and Add Support for Range Queries in Calendar Operations #25
Implement Date Component Differences and Add Support for Range Queries in Calendar Operations #25
Conversation
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Szymon.
|
Added my missing email to GitHub account |
This looks great, but can you drop a couple tests for the logic into https://github.com/skiptools/skip-foundation/blob/main/Tests/SkipFoundationTests/DateTime/TestCalendar.swift, so we can be sure that the SkipFoundation version behaves the same as CoreFoundation? |
@marcprux |
Ok, I think Now I'm down. Went tru few iteration but it does match Swift now |
The |
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.
Looks great overall! Just a couple of review comments and a passing CI run and this can get merged.
Regarding the test. |
Looks good. I think that assertion can be disabled, because we don't support any calendar other than Gregorian yet. Feel free to just remove the assertion. |
done, deal |
Tests all pass. Thanks for the contribution! |
Here’s the updated PR description to reflect the new changes, which now include additional support for
range(of:in:for:)
, handling ofweekOfMonth
,weekOfYear
,day
, and other calendar components:Summary
This PR resolves the previously missing logic for calculating date component differences between a
date
and anendDate
in theDateComponents
initializer and adds support for various date operations. Previously, the initializer contained afatalError
for handling date field differences, causing crashes when using certain date-based operations. Additionally, we now provide support for more calendar component-based operations such asrange(of:in:for:)
forday
,weekOfMonth
,weekOfYear
, and more.Changes:
date
andendDate
for components such asera
,year
,month
,day
,hour
,minute
,second
,weekday
,weekOfMonth
, andweekOfYear
.range(of:in:for:)
with components likeday
,weekOfMonth
,weekOfYear
withinmonth
andyear
.range(of: .day, in: .month, for: date)
returns the valid range of days in a month.nil
endDate
: IfendDate
is not provided, the initializer simply extracts the component values from the givendate
.java.util.Calendar
(e.g.,nanosecond
,quarter
,yearForWeekOfYear
) have been commented out for future handling.Testing
weekOfMonth
,weekOfYear
, andday
for better date component handling.Impact
This update resolves crashes caused by the unimplemented date field difference logic and ensures proper handling of date ranges across the application.
The added range support now enables users to query calendar components such as days in a month, weeks in a month, and weeks in a year, improving date-related functionality.
REQUIRED: I have signed the Contributor Agreement
REQUIRED: I have tested my change locally with
swift test
OPTIONAL: I have tested my change on an iOS simulator or device
OPTIONAL: I have tested my change on an Android emulator or device