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.
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 add: Sum mixed SI duration terms in nanoseconds and return the exact rational in a target unit.
- Duration compare: Compare two SI duration amounts after converting both to nanoseconds.
- ISO date add: Add a signed whole-day delta to a strict YYYY-MM-DD calendar date.
- ISO date age: Compute the calendar-aware elapsed years, months, and days between a birth date and an as-of date.
- ISO date business day add: Add a signed count of business days to a date, skipping caller-supplied weekend weekdays and holidays.
- ISO date business days count: Count the business days in an inclusive date range, skipping caller-supplied weekend weekdays and holidays.