Skip to content

feat(core): time-add, time-before?, time-after?#132

Merged
jig merged 1 commit into
developfrom
feat/time-add-compare
Jul 24, 2026
Merged

feat(core): time-add, time-before?, time-after?#132
jig merged 1 commit into
developfrom
feat/time-add-compare

Conversation

@jig

@jig jig commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Adds calendar/duration arithmetic and ordering over the epoch-millisecond ints that time-ms / time-format already use.

(time-add ms deltas)

deltas is a hash-map; :years :months :days are calendar-aware (via time.AddDate, in UTC), :hours :minutes :seconds :milliseconds add a fixed duration. Missing keys are 0, negatives shift backwards. An unknown key or a non-integer value is a catchable error. The map is read, never mutated.

(time-format (time-add 0 {:hours 1 :minutes 30}))   ; => "1970-01-01T01:30:00.000Z"
(time-format (time-add (time-parse "2020-01-31T00:00:00Z") {:months 1}))
                                                     ; => "2020-03-02T00:00:00.000Z"

Overflow normalises like Go's AddDate (Jan 31 + 1 month → March 2, Feb 29 + 1 year → March 1) — documented on the builtin and covered by tests.

(time-before? t1 t2) / (time-after? t1 t2)

Strict ordering of two epoch-millisecond ints.

Docs (docs.go, regenerated LANGUAGE.md) and tests updated; both the untagged and -tags debugger suites pass locally.

🤖 Generated with Claude Code

Calendar/duration arithmetic and ordering over the epoch-millisecond
ints that time-ms/time-format already use:

- (time-add ms {:years .. :months .. :days .. :hours .. :minutes ..
  :seconds .. :milliseconds ..}) — years/months/days go through
  time.AddDate (calendar-aware, overflow normalised like Go: Jan 31 +
  1 month -> March 2); the rest add a fixed duration. Missing keys are
  0, negatives shift backwards. Unknown key or non-integer value errors.
  The deltas map is read, never mutated.
- (time-before? t1 t2) / (time-after? t1 t2) — strict ordering.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jig
jig merged commit cc84c9c into develop Jul 24, 2026
14 checks passed
@jig
jig deleted the feat/time-add-compare branch July 24, 2026 08:22
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