# ISO 8601 Duration Parser & Arithmetic Workbench

Parse ISO 8601 durations, validate ISO 8601-2 extensions, run calendar-true arithmetic, sort by real length at an anchor, and diff datetimes.

> Canonical page: https://test.elysiatools.com/en/tools/iso-8601-duration-parser-arithmetic-workbench

- **Category:** Date & Time

- **Keywords:** iso 8601, duration, temporal.duration, calendar arithmetic, kubernetes duration, rrule, icalendar duration, time interval

## Overview

A duration calculator, not a format converter. Four modes: parse & inspect, arithmetic expression, sort by real length, and calendar difference between two datetimes.

## Inputs

- **模式** (select)
- **时长 / 表达式** (textarea): P1Y2M3DT4H5M6S P3W PT36H -PT30M P0D (expression mode) P1Y2M + P11M - P90D
- **锚点时刻** (text): 2026-01-15T00:00:00Z (default)
- **起始时刻** (text): 2026-01-01T00:00:00Z (diff mode)
- **结束时刻** (text): 2026-02-15T12:30:00Z (diff mode)

## When to use

- When parsing and validating standard ISO 8601 or ISO 8601-2 duration strings like P1Y2M, PT36H, or P2W3D.
- When evaluating arithmetic expressions like P1Y2M + P11M - P90D against a specific calendar anchor date.
- When calculating the exact ISO duration between two timestamps or sorting multiple durations by elapsed length.

## How it works

- Select your target workbench mode: Parse & Inspect, Arithmetic Expression, Sort by Real Length, or Datetime Difference.
- Enter your ISO 8601 duration strings, mathematical expression, or start and end timestamps into the designated input fields.
- Specify an anchor datetime to anchor variable-length calendar components such as months and leap years.
- Inspect the parsed component breakdown, canonical ISO representation, or step-by-step arithmetic calculation table.

## Use cases

- Validating Temporal.Duration and iCalendar RRULE intervals for scheduling workflows.
- Evaluating subscription rollups and expiration dates across varying calendar month lengths.
- Calculating exact ISO 8601 intervals between start and end events in system audit logs.

## Frequently asked questions

### What duration formats does the workbench support?

It supports standard designators (P1Y2M3DT4H5M6S), week formats (P3W), time-only offsets (PT36H), negative durations (-PT30M), and ISO 8601-2 combined extensions (P2W3D).

### Why is an anchor datetime needed for duration arithmetic?

Calendar units like months and years do not have fixed lengths, so an anchor timestamp is required to compute accurate day offsets across month boundaries and leap years.

### How does expression mode evaluate duration calculations?

It parses additive and subtractive duration terms, applies them sequentially from the anchor datetime, and reconstructs the resulting difference as a normalized ISO duration.

### How does sorting durations work?

It projects each duration from the specified anchor datetime, measures the exact elapsed seconds, and orders the list from shortest to longest.

### What is the difference between parse mode and diff mode?

Parse mode inspects and normalizes existing duration strings, whereas diff mode calculates the ISO 8601 duration between two distinct datetimes.

## Related tools

- [Date Range Validator](https://test.elysiatools.com/en/tools/date-range-validator): Validate if dates are within a specified range
- [Chess FEN, PGN & Elo Rating Tutor](https://test.elysiatools.com/en/tools/chess-fen-pgn-elo-rating-tutor): Parse & validate FEN board snapshots, PGN/SAN movetext (with parity, check/mate counts, threefold); compute Elo rating updates from win/draw/loss results, with Lichess/Chess.com tier bands
- [Cron Expression Visualizer](https://test.elysiatools.com/en/tools/cron-expression-visualizer): Parse cron schedules, validate standard or Quartz syntax, and visualize the next execution times on a timeline and grouped calendar view
- [CSV Malformed Row Surgeon](https://test.elysiatools.com/en/tools/csv-malformed-row-surgeon): Surgically repair malformed CSV rows one at a time: unescaped (stray) quotes, mixed delimiters (tab/semicolon/comma in the same file), BOM-prefixed headers, CRLF/CR line endings and trailing empty lines. The surgeon parses tolerantly, shows a row-level red/green diff of every change it made (before → after, with the repair reason tagged), lists the rows it accepted unchanged, and emits the cleaned CSV. Optional AI repair can review suspicious rows after the deterministic pass. It complements the CSV Validator (which only reports problems) by actually fixing the damaged rows.
- [HTTP Link Header RFC 8288 Parser and Pagination Crawler Preview](https://test.elysiatools.com/en/tools/http-link-header-rfc8288-parser-and-pagination-crawler-preview): Parse RFC 8288 Link headers with the spec appendix-B algorithm, resolve relative URI-references against a base URL, classify rel types against the IANA registry, validate preload/prefetch hints, and simulate how a rel="next" pagination crawler walks your responses — including cycle detection.
- [Security Headers Checker](https://test.elysiatools.com/en/tools/security-headers-checker): Audit HTTP response headers for security compliance — parses the raw headers you paste (no network) and grades them against the OWASP secure-header set with value-level checks: HSTS max-age, CSP unsafe-inline/eval, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, COOP/COEP/CORP and more. Outputs a letter grade (A+ to F) plus per-header findings with copy-ready fix recommendations.
- [SMT-LIB 2.7 / AIGER / BTOR2 Formal Verification Orchestrator (CDCL + BMC + k-Induction + Craig Interpolation + IC3)](https://test.elysiatools.com/en/tools/smt-smtlib-2-7-cvc5-z3-btor2-aiger-k-induction-cddr-dbg-invariant-synthesis-orchestrator): A complete in-browser formal-verification stack — no cvc5/Z3 binary needed: an SMT-LIB 2.7 script parser for the QF_BV + Bool core with Tseitin bit-blasting of the FixedSizeBitVectors operators (add/sub/mul/udiv/urem, shifts, comparators, concat/extract/extend, ite), an AIGER reader (ASCII aag and binary aig with delta decoding; outputs as bad properties), a BTOR2 reader with word-level bit-blasting, and a hand-written CDCL SAT engine (two-watched literals, VSIDS-style activities, 1-UIP learning, restarts) underneath. On sequential models it runs bounded model checking with counterexample-witness traces, k-induction with unique-state strengthening, McMillan-style Craig interpolation computed from the refutation and independently re-certified by SAT before being trusted, and an IC3/PDR-lite frame loop with predecessor-cube blocking.
- [US Sailplane IGC / XCscore / FAI Badge Flight Validator](https://test.elysiatools.com/en/tools/us-sailplane-soaring-xcscore-flight-igc-fai-badge-declaration-validator): Parse an FAI IGC flight-recorder file (A/H/I/C/B/F/L/G records) end to end and audit it like a badge secretary: takeoff/release/landing detection (ENL engine-noise or tow kinematics), total altitude gain, OLC/XCscore-style optimal free distance over the convex hull, best FAI triangle against the 28% shortest-side rule, out-and-return distance, pre-flight C-record declaration chain (declared-before-takeoff, task shape, FAI triangle check), loss-of-height rules, and the G-record security audit with signed-stream coverage reconstruction (H O/P and non-manufacturer L records excluded per the IGC specification). Evaluates Silver / Gold / Diamond badge elements and the 750 km + 250 km diploma ladder.

## Samples

- [Nginx Log Parser Samples](https://test.elysiatools.com/en/samples/nginx-log-samples): Comprehensive Nginx log samples for testing log-parser tool, including access logs and error logs with various formats and scenarios
- [ISO Viewer Samples](https://test.elysiatools.com/en/samples/iso-viewer-samples): A ISO archive sample for in-browser preview
- [Android Image Processing Java Samples](https://test.elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://test.elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion

## Related content

- [Define an ISO 8601 Reporting Period and Fiscal Week](https://test.elysiatools.com/en/hubs/iso-8601-reporting-period-and-fiscal-week): Turn a dated reporting anchor and a stated duration into an auditable calendar endpoint, ISO week label and fiscal-quarter assignment.
