Code blocks in this file serve as integration tests.
- ../cli.rs invokes
trycmd
; trycmd
executes the commands from each Markdown code block and compares the output of the execution to the output in the code block.
$ unmillis --help
Converts millisecond-precision UNIX timestamps to the more human-readable and as-precise RFC3339 form.
Usage: unmillis <TIMESTAMP_MILLIS>
Arguments:
<TIMESTAMP_MILLIS>
A timestamp formulated as the number of milliseconds since "1970-01-01T00:00:00+00:00".
• Trailing and leading garbage is thrown away, i.e.
• `1 hello there`, `1,` and `"1",` would all be interpreted as `1`.
• Negative numbers are fine, positive numbers are ok too, both have some limitations:
• We can't construct datetimes outside the range of (-262144-01-01T00:00:00Z, +262143-12-31T23:59:59.999999999Z), so
• we only accept input values in the range of (-8334632851200000, 8210298412799999)
Options:
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
$ unmillis --version
unmillis [..]
$ unmillis -10
1969-12-31T23:59:59.990+00:00
$ unmillis 1640995200000
2022-01-01T00:00:00+00:00
$ unmillis 1640995200000th
2022-01-01T00:00:00+00:00
$ unmillis 1640995200000,
2022-01-01T00:00:00+00:00
$ unmillis '"1640995200000",'
2022-01-01T00:00:00+00:00
The
? n
line indicates the expected exit code, e.g.? 1
in$ unmillis 9223372036854775808 ? 1
will assert that the exit code is
1
.
$ unmillis 9223372036854775808
? 1
Error: Failed to parse timestamp millis from "9223372036854775808"
Caused by:
0: could not parse integer from trimmed string "9223372036854775808"
1: number too large to fit in target type
We're limited by chrono
$ unmillis 1111111111111111111
? 1
Error: could not generate RFC 3339 datetime from millis: 1111111111111111111
Caused by:
FromTimestamp error: Sorry, we can't handle timestamps outside the range (-8334601228800000, 8210266876799999), because we can't represent datetimes outside the range (-262143-01-01T00:00:00Z, +262142-12-31T23:59:59.999999999Z)
$ unmillis
? 2
error: the following required arguments were not provided:
<TIMESTAMP_MILLIS>
Usage: unmillis <TIMESTAMP_MILLIS>
For more information, try '--help'.
$ unmillis nine
? 1
Error: Failed to parse timestamp millis from "nine"
Caused by:
0: could not parse integer from trimmed string ""
1: cannot parse integer from empty string
$ unmillis nine hundred
? 2
error: unexpected argument 'hundred' found
Usage: unmillis <TIMESTAMP_MILLIS>
For more information, try '--help'.
$ unmillis '16409hellothere95200000'
? 1
Error: Failed to parse timestamp millis from "16409hellothere95200000"
Caused by:
0: could not parse integer from trimmed string "16409hellothere95200000"
1: invalid digit found in string
$ unmillis 1337beefcafe1337
? 1
Error: Failed to parse timestamp millis from "1337beefcafe1337"
Caused by:
0: could not parse integer from trimmed string "1337beefcafe1337"
1: invalid digit found in string