Duration convert
duration-convert · version 1.0.0 · Dates & times (UTC, ISO 8601) · free, no key needed
Convert a canonical integer duration between nanosecond-based SI units as an exact rational.
Use when you need to: duration convert · convert duration units · convert seconds minutes hours days.
Decide before calling
Read the versioned contract and the supported scope below. Reuse duration-convert@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use duration-convert@1.0.0 for duration convert. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- duration convert
- convert duration units
- convert seconds minutes hours days
Not supported
- months
- years
- weeks
- leap seconds
- ISO-8601 duration strings
- floats
- calendar dates
Behavior
- value is a canonical integer string amount in the from unit; -0 is accepted and canonicalized to 0.
- Units are ns, us, ms, s, min, h, and day from DURATION_NS; day is exactly 86400 seconds.
- Conversion is the exact rational value * from_ns / to_ns, reduced with sign only on the numerator.
- Negative durations are allowed; leap seconds, months, years, and ISO-8601 duration strings are rejected.
- Input integers and the reduced numerator and denominator may have at most 1000 digits excluding sign.
Input
value(string, required): max length 1001; pattern^-?(0|[1-9][0-9]*)$from(one of "ns", "us", "ms", "s", "min", "h", "day", required)to(one of "ns", "us", "ms", "s", "min", "h", "day", required)
Output
numerator(string, required): pattern^(0|-?[1-9][0-9]*)$denominator(string, required): pattern^[1-9][0-9]*$
Limits
- max digits: 1000
- units: ["ns","us","ms","s","min","h","day"]
Example
Request input:
{
"value": "90",
"from": "s",
"to": "min"
}
Response:
{
"result": {
"numerator": "3",
"denominator": "2"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "duration-convert",
"version": "1.0.0",
"input": {
"value": "90",
"from": "s",
"to": "min"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/duration-convert/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"value":"90","from":"s","to":"min"}'
The machine-readable contract is at /v1/tools/duration-convert/versions/1.0.0.
CLI
node cli.mjs run duration-convert 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Duration parse clock: Parse an hh:mm:ss[.fraction] duration and return the exact nonnegative whole or decimal second count.
- ISO duration structure check: Check a claimed reading of an ISO 8601 duration: well-formedness, components and month/day/time totals.
- Duration format clock: Format a nonnegative whole or decimal second count as an exact hh:mm:ss[.fraction] clock duration.
- Working hours total: Total exact elapsed seconds in a versioned working-hours calendar after DST and closure expansion.
- Duration add: Sum mixed SI duration terms in nanoseconds and return the exact rational in a target unit.
- ISO to epoch: Convert a canonical RFC 3339 UTC timestamp to an exact integer Unix epoch count in the requested unit.