parseTemporal silently drops fractional parts on non-second duration units (e.g. `PT0.5H` -> `PT0H`)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Bắt đầu tại parseDuration() trong src/parser.ts: các chữ số phần phân số đã được thu thập trước khi chỉ định đơn vị được đọc, nhưng chỉ nhánh unit === 'S' mới lưu chúng. Đọc kiểu AST cho secondsFraction và nhánh duration của stringifier để xem một trường phân số sẽ được truyền qua như thế nào, rồi quyết định xem nên giữ phần phân số trên H/M/đơn vị ngày hay ném một ParseError. Đoạn repro.mjs của issue là bước kiểm tra: chạy nó với bốn đầu vào và xác nhận đầu ra hoặc giữ nguyên phần phân số hoặc là một lỗi rõ ràng, không phải cắt bỏ âm thầm. Thêm test parser bên cạnh các ca duration hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
parseTemporal accepts decimal fractions (. or ,) on any duration unit without throwing, but only preserves the fraction for seconds (S), silently truncating fractional hours, minutes, and date units to integers.
Playground: https://lxcid.com/tools/temporal-playground/?expr=PT0.5H
npm install @taskade/[email protected]
node repro.mjs
// repro.mjs
import { parseTemporal, stringifyTemporal } from "@taskade/temporal-parser";
for (const input of ["PT0.5H", "PT1.5M", "PT0,5H", "P1.5D"]) {
const ast = parseTemporal(input);
console.log(input, ast, stringifyTemporal(ast));
}
console.log(Temporal.Duration.from(parseTemporal("PT0.5H")).toString());
console.log(Temporal.Duration.from("PT0.5H").toString());
Actual output:
PT0.5H { kind: 'Duration', hours: 0, raw: 'PT0.5H', annotations: [] } PT0H
PT1.5M { kind: 'Duration', minutes: 1, raw: 'PT1.5M', annotations: [] } PT1M
PT0,5H { kind: 'Duration', hours: 0, raw: 'PT0,5H', annotations: [] } PT0H
P1.5D { kind: 'Duration', days: 1, raw: 'P1.5D', annotations: [] } P1D
PT0S
PT30M
Expected output:
ISO 8601 allows a decimal fraction on the lowest-order duration unit (and TC39 Temporal accepts fractions on H, M, and S), so parseTemporal should either preserve fractional non-second components in the AST or throw a ParseError when a fraction appears on an unsupported unit, rather than returning truncated integer fields (hours: 0 / "PT0H").
In src/parser.ts, parseDuration() consumes . / , and the fractional digits into fraction before reading the unit designator, then only stores fraction in the unit === 'S' branch (dur.secondsFraction = fraction) and ignores it in every other unit branch.
Versions: @taskade/[email protected] (main commit 729b967), Node.js v26.13.0 on Linux x64.
Credit: https://ucsbplse.github.io/
- Ngôn ngữ chính
- TypeScript
- Star
- 26
- Fork
- 5
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của taskade/temporal-parser
-
bug: Support time only ISO-8601 formatCó thể đã có người làm @lxcid đã nhận 307 ngày trước. Đang mở
taskade/temporal-parser#13 · 1 reaction · 2 người được giao ·
Tất cả issue của taskade/temporal-parser
Issue tương tự
-
db-d1-sqlite: upsert is aliased to updateOne, so payload.kv.set never inserts new keysCó thể đã có người làm @pcbeingused333 đã nhận hôm nay. Đang mởBug db: d1-sqlite Payload OSS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
payloadcms/payload#19766 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
device-management-toolkit/sample-web-ui#3711 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug impact:low Team: SecuritySolution Team:Defend Workflows v9.6.0
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
elastic/kibana#306401 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
agentes-chat/agentes-chat#927 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Closing a pinned tab jumps to the Tabs section instead of the next open pinned tabCó thể đã có người làm @seenimohamed đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ardia-browser/ardia#2769 ·
Maintainer thường phản hồi trong vòng 1 ngày