Skip to content

Conversation

@itingliu
Copy link
Contributor

Validate the given DateComponents values up front to align with the supported Calendar calculation date range, defined as Date.validCalendarRange.

We could alternatively guard all arithmetic operations with ...reportingOverflow, but there are too many operations, and so it seems untenable. I opted for a more realistic approach instead. _CalendarICU unconditionally truncates values to Int32, so the results for Calendar.date(from:) have always been incorrect for distant dates anyways.

Fixed 129782208

Validate the given `DateComponents` values up front to align with the supported Calendar calculation date range, defined as `Date.validCalendarRange`.

We could alternatively guard all arithmetic operations with `...reportingOverflow`, but there are too many operations, and so it seems untenable. I opted for a more realistic approach instead. `_CalendarICU` unconditionally truncates values to `Int32`, so the results for `Calendar.date(from:)` have always been incorrect for distant dates anyways.

Fixed 129782208
@itingliu
Copy link
Contributor Author

@swift-ci please test

@itingliu itingliu requested a review from parkera June 20, 2024 16:12
@itingliu itingliu merged commit f7882fe into swiftlang:main Jun 20, 2024
@itingliu itingliu deleted the date-components-validation branch June 20, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants