into duration
for conversions
Convert value to duration.
Signature
> into duration {flags} ...rest
Flags
--unit, -u {string}
: Unit to convert number into (will have an effect only with integer input)
Parameters
...rest
: For a data structure input, convert data at the given cell paths.
Input/output types:
input | output |
---|---|
duration | duration |
int | duration |
string | duration |
table | table |
Examples
Convert duration string to duration value
> '7min' | into duration
7min
Convert compound duration string to duration value
> '1day 2hr 3min 4sec' | into duration
1day 2hr 3min 4sec
Convert table of duration strings to table of duration values
> [[value]; ['1sec'] ['2min'] ['3hr'] ['4day'] ['5wk']] | into duration value
╭───┬───────╮
│ # │ value │
├───┼───────┤
│ 0 │ 1sec │
│ 1 │ 2min │
│ 2 │ 3hr │
│ 3 │ 4day │
│ 4 │ 5wk │
╰───┴───────╯
Convert duration to duration
> 420sec | into duration
7min
Convert a number of ns to duration
> 1_234_567 | into duration
1ms 234µs 567ns
Convert a number of an arbitrary unit to duration
> 1_234 | into duration --unit ms
1sec 234ms
Notes
Max duration value is i64::MAX nanoseconds; max duration time unit is wk (weeks).