{"uid":"cap_1Hay7OCuINTrCF41mbbGr","slug":"iso-8601-duration-parser-a70afe81","name":"ISO 8601 Duration Parser","description":"Parse an ISO 8601 duration such as 'P1Y2M10DT2H30M' into its components. Returns a normalized ISO string and totalSeconds — but totalSeconds is null when the duration contains years or months, because those are calendar-variable (use /v1/add or /v1/between for exact date math).","url":"https://datetime.openverbs.com/v1/parse","method":"POST","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method","bodyType","body"],"properties":{"body":{"type":"object","required":["duration"],"properties":{"duration":{"type":"string","maxLength":128,"minLength":2,"description":"ISO 8601 duration, e.g. 'P3W' or 'PT1H30M'."}},"additionalProperties":false},"type":{"type":"string","const":"http"},"method":{"enum":["POST"],"type":"string"},"bodyType":{"enum":["json","form-data","text"],"type":"string"}},"additionalProperties":false}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_zoTF86M7QCS0Xac05nZ2C","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Parses an ISO 8601 duration string into its component parts and returns a normalized ISO string plus totalSeconds (null when years or months are present).","exampleAgentPrompt":"Parse the ISO 8601 duration 'P1Y2M10DT2H30M' and tell me what each component means — years, months, days, hours, minutes — and give me the total seconds if you can.","exampleUseCases":[{"title":"Decoding subscription billing interval","prompt":"I have a billing cycle stored as 'P1Y' — can you parse that ISO 8601 duration and tell me what each part represents and how many seconds it equals?"},{"title":"Validating API duration field","prompt":"Our API is returning 'PT1H30M' as a duration value — parse it for me and show me the individual time components so I can confirm it's correct."},{"title":"Displaying human-readable countdown","prompt":"I need to break down the duration 'P2DT4H30M' into its component parts — days, hours, minutes — so I can display each piece separately in the UI."}],"resultDescription":"Returns a normalized ISO 8601 duration string and an object with individual components (years, months, weeks, days, hours, minutes, seconds). Also returns totalSeconds as a number when the duration contains no years or months (since those are calendar-variable); totalSeconds is null if years or months are present.","failureModes":["Invalid ISO 8601 duration string returns a 400 error","Duration string shorter than 2 characters rejected by schema validation","Malformed input (e.g. missing 'P' prefix) returns parsing error","totalSeconds is null for durations containing years or months — not an error but may surprise callers expecting a numeric result","Empty body or missing 'duration' field returns schema validation error"],"whenToPreferThis":"Use this endpoint when you need to decompose or normalize an ISO 8601 duration string into its individual components (years, months, days, hours, minutes, seconds), or to get totalSeconds for fixed-length durations. If you need to add a duration to a specific date or compute the duration between two dates, prefer the /v1/add or /v1/between sibling endpoints instead. This is the right choice when the goal is purely parsing and understanding a duration string, not performing date arithmetic.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T00:43:22.634Z","isFirstParty":false}