Skip to content

Comments

Added support for nextDate and enumerateDates to Calendar#93

Open
fhasse95 wants to merge 27 commits intoskiptools:mainfrom
fhasse95:Added-Calendar-Enumeration-Support
Open

Added support for nextDate and enumerateDates to Calendar#93
fhasse95 wants to merge 27 commits intoskiptools:mainfrom
fhasse95:Added-Calendar-Enumeration-Support

Conversation

@fhasse95
Copy link
Contributor

@fhasse95 fhasse95 commented Feb 14, 2026

This PR extends the Calendar class to include support for nextDate and enumerateDates.

The core logic was primarily adapted from the Swift Foundation repository repository to ensure parity with the native Swift behavior and minimize the risk of logic errors inherent in a full reimplementation. Since Skip currently only supports the Gregorian calendar, non-essential special cases were removed (e.g., lunar calendar offsets).

To ensure stability, I added several unit tests covering ranges, intervals, and enumeration. However, due to the complexity of calendar edge cases, it's possible that I overlooked a scenario.

Therefore, if you notice anaything, please let me know! 😊


Thank you for contributing to the Skip project! Please use this space to describe your change and add any labels (bug, enhancement, documentation, etc.) to help categorize your contribution.

Please review the contribution guide at https://skip.dev/docs/contributing/ for advice and guidance on making high-quality PRs.

Skip Pull Request Checklist:

  • 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

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

I used AI for assistance in creating additional unit tests for the calendar components and for consulting on Java-specific Calendar behaviors. Verification was done by manually reviewing all test cases, adjusting range expectations to match platform-specific constants, and ensuring the tests pass on both environments.


@cla-bot cla-bot bot added the cla-signed label Feb 14, 2026
var previouslyReturnedMatchDate: Date? = nil
var iterations = -1

repeat {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This STOP_EXHAUSTIVE_SEARCH_AFTER_MAX_ITERATIONS approach seems rather heavy-handed to me. I assume there's no equivalent function in Java's Calendar logic?

How does Foundation's Calendar do it?

Copy link
Contributor Author

@fhasse95 fhasse95 Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, Java's Calendar does not have a direct native equivalent to Apple's enumerateDates function which is why I decided to base the implementation on the logic found in the Swift Foundation library.

I agree that this approach seems heavy-handed for preventing infinite loops. However, the Swift Foundation implements it in exactly the same way (see: https://github.com/swiftlang/swift-foundation/blob/main/Sources/FoundationEssentials/Calendar/Calendar_Enumerate.swift#L472C9-L472C62).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants