Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#9,888 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@jayhemnani9910 đang làm issue này rồi.

Từ ngày 24/10/2026.

  • #9891 của @jayhemnani9910 — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api

Hướng nghiên cứu

A working branch (feat/duration-iso) and open PR #9891 already implement the proposed Duration.formatIso, fromIso and Schema.DurationFromIsoString. Review that PR and the issue's exact unit rules, then check output against Temporal.Duration#toString(). Coordinate with the existing contributor before doing further work.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

What is the problem this feature would solve?

v3 had Duration.formatIso, Duration.fromIso and Duration.unsafeFormatIso (#4343, for #4319). v4 dropped them, and the migration guide says to "retain a local formatter" or use a separate ISO parser.

ISO 8601 durations are a common wire format: OpenAPI format: duration, config files (timeout: PT30S), Temporal.Duration#toString(). In v4 each app needs its own parser, and there is no Schema codec.

v3 also treated a year as 365 days and a month as 30 days, so P1M was wrong for most months.

What is the feature you are proposing to solve the problem?
Duration.formatIso(self: Duration): Option<string>
Duration.fromIso(input: string): Option<Duration>
Schema.DurationFromIsoString // string <-> Duration, JSON Schema format: "duration"
  • Exact units only: W, D, H, M (after T), S. A day is 24 hours.
  • Y and month M are rejected, since they have no fixed length.
  • Optional sign, fraction on the last time unit only, up to 9 digits.
  • Output matches Temporal.Duration#toString(): P1DT2H3M4.5S, PT0S, -PT1.5S.
  • Infinite durations give Option.none() (and an encode failure in the codec).
What alternatives have you considered?
  • A local helper in each app, which is what the migration guide suggests.
  • Duration.fromInput(Temporal.Duration.from(s)), but Node 24 has no Temporal without a flag, and it gives no Schema codec.

I have a working branch with tests (checked against Temporal.Duration where available): https://github.com/jayhemnani9910/effect/compare/main...feat/duration-iso. I can open a PR if this direction is OK.

Ngôn ngữ chính
TypeScript
Star
16.7k
Fork
808
Merge trung bình
10 giờ 33 phút
Pull request đã merge (30 ngày)
830

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Effect-TS/effect

Tất cả issue của Effect-TS/effect

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.