Add date filters: Seconds, Minutes, Hours, Days, Weeks, Months, TimeSpan - #126
Closed
NickJosevski wants to merge 1 commit into
Closed
Add date filters: Seconds, Minutes, Hours, Days, Weeks, Months, TimeSpan#126NickJosevski wants to merge 1 commit into
NickJosevski wants to merge 1 commit into
Conversation
… time spans AddSeconds, AddMinutes, AddHours, AddDays and AddWeeks shift by a fixed duration and accept negative and fractional amounts. AddTimeSpan covers compound shifts. All output round-trip format so they chain into Format, and they can be chained together to combine units. AddMonths shifts by calendar month rather than a fixed duration, so it takes whole months only and clamps the day to the end of a shorter month: 31 Jan plus one month is 28 Feb. Time zone shape is preserved throughout: naive stays naive, UTC stays UTC, and an explicit offset is kept rather than converted to server-local. Note the .NET TimeSpan format reads the leading field as days once it goes above 23, so AddTimeSpan 48:00:00 is 48 days where AddHours 48 is 48 hours. That is silent, so it is pinned by a test and called out in the docs. Raised from ticket 215987 — deriving a ServiceNow change window from a deployment's start time, from the Octopus UI, with no CLI or script step in the path to compute it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Aug 10, 2026
Contributor
Author
|
Closing — going with the |
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.
All PRs in this change
Three variants of the same feature — pick one row, the other two get closed.
AddHours+AddDaysAddTimeSpanonlyAddTimeSpanMerge order is the same for every variant: Octostache first, then the package publishes, then Docs and Server. Calamari additionally needs its
Octostache 3.9.2pin bumped, so it stays red until then.What
The full set, so nothing is missing and
AddTimeSpanisn't the only option.AddSecondsAddMinutesAddHoursAddDaysAddWeeksAddMonthsAddTimeSpan{days}.{hours}:{minutes}:{seconds}Fractional amounts need quoting (
AddHours "1.5") —.isn't valid in an unquoted filter argument. Time zone shape is preserved: naive stays naive, UTC stays UTC, an explicit offset is kept rather than converted to server-local.What reviewers should look at
1.
AddMonthsis not a duration. Calendar months vary in length, so it usesDateTime.AddMonths, takes whole months only, and clamps the day:2030-01-31AddMonths 12030-02-282032-01-31AddMonths 12032-02-29(leap)2030-03-31AddMonths -12030-02-28So
AddMonths 1 | AddMonths -1is not always identity.AddMonths "1.5"is rejected rather than rounded.2.
AddTimeSpan 48:00:00is 48 days, not 48 hours — the{hours}field only holds 0–23, so above that the leading field becomes{days}and the rest shift along. Silent, and inherent to the .NET format. This variant is the only one where the docs can point at an unambiguous alternative in the same release:AddHours 48. A test contrasts the two directly.Implementation
One
Shiftcore owns parsing, time-zone shape and formatting.AddDurationadapts the five fixed-duration filters viaFunc<double, TimeSpan>;AddMonthsandAddTimeSpancallShiftdirectly. Same delegate-parameterised helper shape asHashFunction.Tests
628 passing — every unit, negatives, fractionals, month clamping both directions and across a leap year, whole-month rejection, the
AddTimeSpanvsAddHours48 contrast, quoting, chained filters, offset preservation, chaining offNowDate/NowDateUtc, echo-on-bad-input.🤖 Generated with Claude Code