Repository navigation
docs: a month or year shift of a short date range can be empty - #269
Merged
Merged
Conversation
#223's rule moves a LocalDateRange's start and the day after its end, and each clips to a shorter month on its own, so a short range ending on the 28th to 31st can come out with nothing between them: [2024-02-28,2024-02-28] moved a year is Empty. PostgreSQL gives the same for the daterange, and LocalDateTimeRange for [2024-02-28,2024-02-29). The maintainer kept the rule (#259); this documents it. docs/ranges.md says when Shift returns Empty, R28's quote follows the reworded sentence, R31 names the cases and R45 holds them. NodaTimeShiftExpandTests pins the analysis's cases and sweeps every day from December 2023 to March 2025, lengths 0 to 35, five steps, holding the date range equal to the date-time range over the same days; CalendarShiftAgreementTests asks PostgreSQL. With the old rule restored, the unit test fails. Closes #259 Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # test/CodoMetis.ValueRanges.NodaTime.Tests/NodaTimeShiftExpandTests.cs # test/oracles/claims.json
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.
Closes #259
Problem
#223's month rule moves a
LocalDateRange's start and the day after its end, and each clips to a shorter month on its own. So a short range ending on the 28th to 31st can come out with nothing between its bounds:[2024-02-28,2024-02-28].Shift(Period.FromYears(1))isEmpty. PostgreSQL gives the same answer for thedaterange, and so doesLocalDateTimeRangefor[2024-02-28,2024-02-29). But claim R28 saidShift"keeps the shape", and the docs mentionedEmptyonly for a negativeExpand. The maintainer decided to keep the rule and document it.Change
Empty", gives the example, the PostgreSQL andLocalDateTimeRangeparity, and when it happens (a range ending on the 28th to 31st, a few days long at most). It also says a whole month never empties.DateRangehas no period shifts (it steps by days), andYearMonthRangesteps by whole months, so neither can empty this way. Nothing changes in code.Tests
NodaTimeShiftExpandTests.LocalDateRange_ShortRangeByMonths_CanBeEmpty_AsLocalDateTimeRangeIs:LocalDateRange([2024-02-28]byP1Y,[2024-03-30]and[2024-01-29]byP1M,[2023-12-30]byP-1M) and theLocalDateTimeRangesiblingLocalDateRangeequal to theLocalDateTimeRangeover the same days,[start, end + 1),Emptyincluded, and asserts the sweep reaches empty results.CalendarShiftAgreementTests(integration). Seven rows compareLocalDateRange.Shiftwith PostgreSQL'sdaterange(start + interval, end + 1 + interval), four of which PostgreSQL empties.end.Plus(delta)), the unit test fails.dotnet test: NodaTime 237, conventions 399, integrationCalendarShiftAgreementTests7, all green.🤖 Generated with Claude Code