Use a Gregorian calendar for --due-date components - #114
Merged
Merged
Conversation
EKReminder.dueDateComponents only accepts DateComponents whose calendar is Gregorian or nil. Calendar.current follows the user's calendar setting, so with e.g. the Japanese calendar every --due-date aborted with 'Calendar must be nil or Gregorian'. Build the test expectations with a Gregorian calendar as well so the tests don't depend on the machine's calendar setting.
keith
approved these changes
Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EKReminder.dueDateComponentsonly acceptsDateComponentswhosecalendaris Gregorian ornil.NaturalLanguage.swiftbuilds them withCalendar.current, which follows the calendar the user picked inSystem Settings > General > Language & Region. With a non-Gregorian calendar (e.g. Japanese or Buddhist),
every
--due-dateaborts:It happens for every
--due-datespelling (2026-09-30,2026-09-30 10:00,tomorrow at 10am).edit --due-datefrom #108 goes through the same parser, so it is affected as well.To reproduce without changing the system-wide setting, set the locale for
remindersonly:Change
Calendar(identifier: .gregorian)when converting the detectedDateintoDateComponents.Parsing is unchanged:
NSDataDetectorresolves the string into an absoluteDatebefore the calendar isused, and the time zone is still passed explicitly.
setting of the machine running them, and add a test that the parsed components use a Gregorian calendar.
Testing
On macOS 26.6.2 (Xcode, Swift 6.2.1) with the Japanese calendar:
reminders add <list> "test" --due-date tomorrowand--due-date "2026-09-30 10:00"create the reminderinstead of crashing (2.5.1 from Homebrew crashes with the same setting)
swift testonmain: 7 of the existing tests fail with this patch applied to the source only, because theexpectations are built with a Japanese
DateComponents. With the test change, those pass and so does the new test.testTodayNoon,testTonightandtestTomorrowAtTimestill fail on this machine, but they fail onmainaswell, independent of the calendar:
dateComponents(in:from:)on macOS 26 also fills indayOfYear, which theexpectations don't include. I left that out of this PR; CI on
macos-14is not affected.