Skip to content

feat: add Offset.shift/3 for business time arithmetic#31

Merged
hopsor merged 1 commit intomainfrom
feat/offset-shift
Mar 17, 2026
Merged

feat: add Offset.shift/3 for business time arithmetic#31
hopsor merged 1 commit intomainfrom
feat/offset-shift

Conversation

@hopsor
Copy link
Copy Markdown
Owner

@hopsor hopsor commented Mar 17, 2026

Summary

  • Adds OpenHours.Offset.shift/3 to shift a DateTime forward or backward by business time
  • Supports :hour and :minute duration units with positive (forward) or negative (backward) amounts
  • Automatically snaps to next/previous business moment when starting outside business hours
  • Raises clear ArgumentError for unsupported units, zero amounts, or empty schedules

Test plan

  • Forward shift: within slot, across slots, across days
  • Backward shift: within slot, across slots, across days
  • Holidays, shifts, breaks, and weekends are respected
  • Timezone conversion when datetime differs from schedule
  • Edge cases: slot boundaries, large durations, minutes unit
  • Error handling: unsupported unit, zero amount, empty schedule
  • Full test suite passes (73 tests, 0 failures)

🤖 Generated with Claude Code

Adds the ability to shift a DateTime forward or backward by a given
amount of business hours or minutes, skipping non-working hours,
weekends, holidays, and breaks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hopsor hopsor merged commit f46a26c into main Mar 17, 2026
3 checks passed
@hopsor hopsor deleted the feat/offset-shift branch March 17, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant