feat(std/time): Date, Weekday and RFC 3339 parsing of Timestamp #390

Merged
argus merged 2 commits from loop/111-date-rfc3339 into main 2026-10-19 23:15:57 +00:00
Collaborator

Closes #111

First slice of gap 11 in docs/design/FIRST-PARTY.md: calendar dates and RFC 3339 parsing in std/time.

What

  • Date (proleptic Gregorian, years 0000 to 9999, UTC, stored as days since 1970-01-01): of, fromDaysSinceEpoch, parse (YYYY-MM-DD), year/month/day, weekday, isLeapYear, daysInMonth, plusDays, daysUntil, startOfDay, plus Compare, Equals, Hash, Show.
  • Weekday (Monday to Sunday, ISO numbers 1 to 7), TimeParseError (Show, Error, with a message that quotes the text and gives the reason).
  • Timestamp.parse (RFC 3339, including the section 5.8 examples, offsets, fractions up to nanoseconds, lowercase t/z) and Timestamp.date. Leap seconds and instants outside the Timestamp range are refused with a reason.
  • capabilityOfImport lists Date, Weekday and TimeParseError as capability-free (test in compiler/tests/capability.test.trb).
  • Docs in docs/standard-library/time.md, docs/tooling/torb-publish.md; gap 11 marked partly done in FIRST-PARTY.md with the follow-ups #387, #388, #389. skills/ and the standard-library index are regenerated.

Also fixed

Timestamp.show overflowed for Int64.minimum nanoseconds (the remainder was negated). It now floors the seconds and keeps the fraction non-negative; a test covers the first instant of the range.

Test

Local, quick checks only:

  • torb test on std/time/tests (60 tests) and compiler/tests/capability.test.trb (13 tests): pass
  • torb format --check, torb lint on the touched files: clean
  • torb docs skill --check: OK
  • tools/check-commits.sh: OK

The bootstrap and the gates run in the forge CI. No seed change.

Closes #111 First slice of gap 11 in `docs/design/FIRST-PARTY.md`: calendar dates and RFC 3339 parsing in `std/time`. ## What - `Date` (proleptic Gregorian, years 0000 to 9999, UTC, stored as days since 1970-01-01): `of`, `fromDaysSinceEpoch`, `parse` (`YYYY-MM-DD`), `year`/`month`/`day`, `weekday`, `isLeapYear`, `daysInMonth`, `plusDays`, `daysUntil`, `startOfDay`, plus `Compare`, `Equals`, `Hash`, `Show`. - `Weekday` (Monday to Sunday, ISO numbers 1 to 7), `TimeParseError` (`Show`, `Error`, with a `message` that quotes the text and gives the reason). - `Timestamp.parse` (RFC 3339, including the section 5.8 examples, offsets, fractions up to nanoseconds, lowercase `t`/`z`) and `Timestamp.date`. Leap seconds and instants outside the `Timestamp` range are refused with a reason. - `capabilityOfImport` lists `Date`, `Weekday` and `TimeParseError` as capability-free (test in `compiler/tests/capability.test.trb`). - Docs in `docs/standard-library/time.md`, `docs/tooling/torb-publish.md`; gap 11 marked partly done in `FIRST-PARTY.md` with the follow-ups #387, #388, #389. `skills/` and the standard-library index are regenerated. ## Also fixed `Timestamp.show` overflowed for `Int64.minimum` nanoseconds (the remainder was negated). It now floors the seconds and keeps the fraction non-negative; a test covers the first instant of the range. ## Test Local, quick checks only: - `torb test` on `std/time/tests` (60 tests) and `compiler/tests/capability.test.trb` (13 tests): pass - `torb format --check`, `torb lint` on the touched files: clean - `torb docs skill --check`: OK - `tools/check-commits.sh`: OK The bootstrap and the gates run in the forge CI. No seed change.
Adds Date (proleptic Gregorian years 0000 to 9999), Weekday and TimeParseError to std/time, and
Timestamp.parse (RFC 3339 date-time, offset applied, leap seconds and instants outside the Int64
nanoseconds refused), Timestamp.date and Date.startOfDay. capabilityOfImport lists the three new
names as capability-free. Timestamp.show no longer overflows at the lowest Int64 nanosecond, so
Timestamp.parse(t.show()) holds for every Timestamp.
docs(std/time): Date, Weekday, TimeParseError and Timestamp.parse
All checks were successful
ci / tier A (linux-x64) (pull_request) Successful in 4m51s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 2m2s
ci / pack the seed (pull_request) Successful in 10s
ci / every host emits the same C (pull_request) Successful in 4m56s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
images / cr.torb.dev/torbscript/registry (push) Has been skipped
images / cr.torb.dev/torbscript/release-sync (push) Has been skipped
images / cr.torb.dev/torbscript/site (push) Has been skipped
ci / commit messages (push) Successful in 4s
ci / what the change touches (push) Successful in 4s
ci / which runners exist (push) Successful in 1s
ci / bootstrap and conformance (windows-x64) (push) Has been skipped
ci / bootstrap and conformance (linux-arm64) (push) Has been skipped
ci / bootstrap and conformance (macos-arm64) (push) Has been skipped
pdisc / pdisc (push) Successful in 11s
ci / the VS Code extension (editors/vscode) (push) Successful in 16s
ci / bootstrap (linux-x64) (push) Successful in 3m33s
ci / cross-compiled on linux-x64 (windows-x64) (push) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (push) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (push) Has been skipped
ci / tier A (linux-x64) (push) Successful in 6m23s
images / cr.torb.dev/torbscript/site:edge (main) (push) Successful in 12m28s
ci / tools/release-sync and tools/registry (linux-x64) (push) Successful in 2m51s
ci / tier B (linux-x64) (push) Successful in 13m39s
ci / pack the seed (push) Has been skipped
ci / every host emits the same C (push) Successful in 4m49s
ci / archives (push) Has been skipped
ci / the playground (torb as WebAssembly) (push) Successful in 2m0s
ci / gates (push) Successful in 0s
8927a418dd
Documents the new declarations in docs/standard-library/time.md, regenerates skills/, and marks gap 11 of
FIRST-PARTY.md as partly done with the follow-up issues.
argus approved these changes 2026-10-19 23:15:56 +00:00
argus left a comment

Checklist (head 8927a41):

  • Tests: ok. date.test.trb and parse.test.trb cover every acceptance row of #111 (leap years, year 0000/9999, pre-1970, known weekdays, invalid dates, all offset/separator/fraction forms, RFC 5.8 examples, leap second, missing offset, trailing garbage, range edges, round trip incl. Int64 limits). capability.test.trb extended. CI green for this head (tier A, bootstrap linux-x64, gates, pdisc).
  • Correctness: ok. I checked the range-edge arithmetic in TextCursor.instant (no overflow at either edge second, the fraction decides at the edges), Date.startOfDay bounds (+-106751 days), the overflow-safe bounds in plusDays, and the Timestamp.show fix for Int64.minimum (floored seconds, non-negative fraction).
  • Scope: ok. Matches #111 exactly; the show() overflow fix is small, tied to the round-trip requirement and tested. No seed change, one capabilityOfImport edit as the issue states.
  • Security/data: ok. No secrets, no new dependencies, no stored-format change.
  • Docs: ok. time.md, torb-publish.md, FIRST-PARTY.md gap 11 marked partly done with #387/#388/#389, skills regenerated, pdisc green.
  • Workflows: none changed.

Non-blocking: none.

Checklist (head 8927a41): - Tests: ok. date.test.trb and parse.test.trb cover every acceptance row of #111 (leap years, year 0000/9999, pre-1970, known weekdays, invalid dates, all offset/separator/fraction forms, RFC 5.8 examples, leap second, missing offset, trailing garbage, range edges, round trip incl. Int64 limits). capability.test.trb extended. CI green for this head (tier A, bootstrap linux-x64, gates, pdisc). - Correctness: ok. I checked the range-edge arithmetic in TextCursor.instant (no overflow at either edge second, the fraction decides at the edges), Date.startOfDay bounds (+-106751 days), the overflow-safe bounds in plusDays, and the Timestamp.show fix for Int64.minimum (floored seconds, non-negative fraction). - Scope: ok. Matches #111 exactly; the show() overflow fix is small, tied to the round-trip requirement and tested. No seed change, one capabilityOfImport edit as the issue states. - Security/data: ok. No secrets, no new dependencies, no stored-format change. - Docs: ok. time.md, torb-publish.md, FIRST-PARTY.md gap 11 marked partly done with #387/#388/#389, skills regenerated, pdisc green. - Workflows: none changed. Non-blocking: none.
argus merged commit 8927a418dd into main 2026-10-19 23:15:57 +00:00
argus deleted branch loop/111-date-rfc3339 2026-10-19 23:15:57 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!390
No description provided.