Skip to content

Add Duration.formatIso, Duration.fromIso and Schema.DurationFromIsoString - #9891

Merged
tim-smart merged 6 commits into
Effect-TS:v4/next-minorfrom
jayhemnani9910:feat/duration-iso
Oct 26, 2026
Merged

tim-smart merged 6 commits into
Effect-TS:v4/next-minorfrom
jayhemnani9910:feat/duration-iso

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Closes #9888.
Closes EFF-2895.

Brings back ISO 8601 durations, exact units only:

Duration.formatIso(Duration.minutes(90)) // Option.some("PT1H30M")
Duration.formatIso(Duration.hours(26))   // Option.some("P1DT2H")
Duration.fromIso("P1W2D")                // Option.some(Duration.days(9))
Duration.fromIso("P1M")                  // Option.none()
Schema.DurationFromIsoString             // string <-> Duration, JSON Schema { type: "string" }
  • Units W, D, H, M (after T), S. A day is 24 hours, a week 7 days. Y and month M are rejected, since they have no fixed length.
  • Optional sign. A fraction (. or ,, up to 9 digits) is allowed on the last time unit only.
  • Output is balanced into days, hours, minutes and seconds (P1DT2H3M4.5S, PT0S, -PT1.5S); weeks are never emitted.
  • Infinite durations give Option.none() from formatIso, and encoding fails in the codec.
  • The JSON Schema carries no format: "duration": JSON Schema / OpenAPI define it as RFC 3339 Appendix A, which forbids signs, fractions and mixed weeks, so validators would reject values this codec emits.

Testing

  • test/Duration.test.ts: formatIso, fromIso (accepted and rejected inputs, millis vs nanos representation) and round trip.
  • test/schema/Schema.test.ts and toJsonSchemaDocument.test.ts: decode/encode of DurationFromIsoString and its JSON Schema.

@changeset-bot

changeset-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7a0d93a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
effect Minor
@effect/opentelemetry Minor
@effect/vitest Minor
@effect/ai-anthropic Minor
@effect/ai-cloudflare Minor
@effect/ai-openai-compat Minor
@effect/ai-openai Minor
@effect/ai-openrouter Minor
@effect/ai-typesafe Minor
@effect/atom-react Minor
@effect/atom-solid Minor
@effect/atom-vue Minor
@effect/platform-browser Minor
@effect/platform-bun Minor
@effect/platform-deno Minor
@effect/platform-node-shared Minor
@effect/platform-node Minor
@effect/sql-clickhouse Minor
@effect/sql-d1 Minor
@effect/sql-libsql Minor
@effect/sql-mssql Minor
@effect/sql-mysql2 Minor
@effect/sql-pg Minor
@effect/sql-pglite Minor
@effect/sql-sqlite-bun Minor
@effect/sql-sqlite-do Minor
@effect/sql-sqlite-node Minor
@effect/sql-sqlite-react-native Minor
@effect/sql-sqlite-wasm Minor
@effect/docgen Minor
@effect/doctest Minor
@effect/graphql-generator Minor
@effect/openapi-generator Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-bot
effect-bot changed the base branch from main to v4/next-minor October 24, 2026 08:19
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 39.31 KB 39.31 KB 0.00 KB (0.00%)
basic.ts 7.17 KB 7.17 KB 0.00 KB (0.00%)
batching.ts 11.04 KB 11.04 KB 0.00 KB (0.00%)
brand.ts 6.83 KB 6.83 KB 0.00 KB (0.00%)
cache.ts 11.47 KB 11.47 KB 0.00 KB (0.00%)
config.ts 22.73 KB 22.73 KB 0.00 KB (0.00%)
differ.ts 21.86 KB 21.86 KB 0.00 KB (0.00%)
http-client.ts 26.70 KB 26.70 KB 0.00 KB (0.00%)
http-router.ts 36.64 KB 36.64 KB 0.00 KB (0.00%)
logger.ts 11.86 KB 11.86 KB 0.00 KB (0.00%)
metric.ts 9.40 KB 9.40 KB 0.00 KB (0.00%)
optic.ts 7.04 KB 7.04 KB 0.00 KB (0.00%)
pubsub.ts 15.95 KB 15.95 KB 0.00 KB (0.00%)
queue.ts 12.75 KB 12.75 KB 0.00 KB (0.00%)
schedule.ts 11.72 KB 11.72 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.98 KB 13.98 KB 0.00 KB (0.00%)
schema-binary.ts 41.02 KB 41.02 KB 0.00 KB (0.00%)
schema-class.ts 21.52 KB 21.52 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.49 KB 29.49 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.87 KB 27.87 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.24 KB 15.24 KB 0.00 KB (0.00%)
schema-string.ts 12.22 KB 12.22 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.16 KB 16.16 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.85 KB 38.85 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 26.05 KB 26.05 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.79 KB 20.79 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.94 KB 20.94 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.04 KB 21.04 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.07 KB 26.07 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.12 KB 21.12 KB 0.00 KB (0.00%)
schema.ts 20.72 KB 20.72 KB 0.00 KB (0.00%)
stm.ts 14.06 KB 14.06 KB 0.00 KB (0.00%)
stream.ts 10.31 KB 10.31 KB 0.00 KB (0.00%)

jayhemnani9910 and others added 6 commits October 26, 2026 20:48
Add Duration.formatIso, Duration.fromIso, and Schema.DurationFromIsoString.
Only exact units are supported; years and months are rejected because
they have no fixed length.
Drop Temporal comparison tests and redundant cases, and expect no
JSON Schema format annotation for DurationFromIsoString.
RFC 3339 durations reject the signed and fractional forms the encoder
emits. Also restore the ISO helpers in the v3 migration guide.
@tim-smart
tim-smart merged commit 2286214 into Effect-TS:v4/next-minor Oct 26, 2026
10 checks passed
@effect-bot effect-bot mentioned this pull request Oct 26, 2026
tim-smart pushed a commit that referenced this pull request Oct 26, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 26, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
tim-smart pushed a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit to yordis/effect that referenced this pull request Oct 27, 2026
…ring (Effect-TS#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
tim-smart pushed a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
tim-smart pushed a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
tim-smart pushed a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
tim-smart pushed a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 27, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit to wmaurer/effect that referenced this pull request Oct 27, 2026
…ring (Effect-TS#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit to wmaurer/effect that referenced this pull request Oct 27, 2026
…ring (Effect-TS#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit to wmaurer/effect that referenced this pull request Oct 27, 2026
…ring (Effect-TS#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit to wmaurer/effect that referenced this pull request Oct 27, 2026
…ring (Effect-TS#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 28, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit to wmaurer/effect that referenced this pull request Oct 28, 2026
…ring (Effect-TS#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit to wmaurer/effect that referenced this pull request Oct 28, 2026
…ring (Effect-TS#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit to wmaurer/effect that referenced this pull request Oct 28, 2026
…ring (Effect-TS#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 28, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit to wmaurer/effect that referenced this pull request Oct 28, 2026
…ring (Effect-TS#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
effect-bot added a commit that referenced this pull request Oct 28, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
tim-smart pushed a commit that referenced this pull request Oct 28, 2026
…ring (#9891)

Co-authored-by: Effect Bot <tech-ops@effectful.co>
@jayhemnani9910
jayhemnani9910 deleted the feat/duration-iso branch November 13, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duration: ISO 8601 format/parse and a Schema codec (exact units only)

4 participants