Repository navigation
Harden the date engine: clamp events, cache the grid, follow day changes and locale weekends - #150
Merged
Merged
Conversation
A review of MonthGrid, event bucketing and the data source cache, each suspected edge case pinned as a test first. Two DST cases and Hebrew leap years already passed; four did not. - Event bucketing is clamped to the displayed months. An event ending in the year 4000 looped day by day for 13 seconds on the main thread; open-ended system events would have done the same. - The data source is asked for its range once per reload instead of on every cell access (about 150 calls per reload before). The grid and the today index path are cached between reloads; reloadData refreshes them. - The today marker follows midnight and clock or time zone changes: the view reloads on NSCalendarDayChanged and significantTimeChangeNotification. - CalendarView.calendar carries style.locale when style.calendar has no locale of its own, so weekends follow the locale (Friday and Saturday for ar_SA) instead of falling back to Saturday and Sunday. - New EngineTests suite: every day of a DST year round-trips with its first and last minute, Chile's day that starts at 01:00 matches startOfDay, far-off events are clamped, the data source is asked at most a handful of times per reload, locale weekends, 13-month Hebrew years, and the today marker after a day change. 72 tests in four suites. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ubk2MsmduPdDLM7FZXFU8C
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.
Summary
A review of the date engine after 2.0.0:
MonthGrid, event bucketing, the data source cache and calendar handling. Each suspected edge case was written as a test first and run against the unchanged code, so every finding below is confirmed, not theoretical. One commit.Confirmed and fixed
startDate()andendDate(). The grid and the today index path are cached and refreshed once per reload;reloadData()refreshes them.NSCalendarDayChangedandUIApplication.significantTimeChangeNotification, which also covers time zone changes.Calendar(identifier:)without a locale falls back to Saturday and Sunday, so an ar_SA calendar marked Sunday instead of Friday.CalendarView.calendarcarriesstyle.localewhen the calendar has none.Checked and already correct
startOfDay; selection on it works.Test plan
xcodebuild -scheme KDCalendar-Package -destination 'platform=iOS Simulator,name=iPhone 17 Pro,OS=26.5' test— 72 tests in 4 suites pass, including the newEngineTestsxcodebuild docbuildcleanxcrun swift-format lint --strict --recursive Sources Tests Example/KDCalendarDemoclean🤖 Generated with Claude Code
https://claude.ai/code/session_01Ubk2MsmduPdDLM7FZXFU8C