#time #human #human-friendly #parser #duration

humantime

A parser and formatter for std::time::{Duration, SystemTime}

10 releases (3 stable)

1.1.1 Feb 28, 2018
1.1.0 Feb 21, 2018
1.0.0 Jun 3, 2016
0.1.3 May 23, 2016

#1 in Date and time

Download history 20030/week @ 2018-06-16 25150/week @ 2018-06-23 25985/week @ 2018-06-30 26353/week @ 2018-07-07 26825/week @ 2018-07-14 27310/week @ 2018-07-21 26350/week @ 2018-07-28 28852/week @ 2018-08-04 29241/week @ 2018-08-11 27096/week @ 2018-08-18 27662/week @ 2018-08-25 28895/week @ 2018-09-01 25685/week @ 2018-09-08

54,580 downloads per month
Used in 549 crates (21 directly)

MIT/Apache

40KB
807 lines

Human Time

Status: stable

Documentation | Github | Crate

Features:

  • Parses durations in free form like 15days 2min 2s
  • Formats durations in similar form 2years 2min 12us
  • Parses and formats timestamp in rfc3339 format: 2018-01-01T12:53:00Z
  • Parses timestamps in a weaker format: 2018-01-01 12:53:00

Timestamp parsing/formatting is super-fast because format is basically fixed.

Here are some micro-benchmarks:

test result: ok. 0 passed; 0 failed; 26 ignored; 0 measured; 0 filtered out

     Running target/release/deps/datetime_format-8facb4ac832d9770

running 2 tests
test rfc3339_chrono            ... bench:         737 ns/iter (+/- 37)
test rfc3339_humantime_seconds ... bench:          73 ns/iter (+/- 2)

test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured; 0 filtered out

     Running target/release/deps/datetime_parse-342628f877d7867c

running 6 tests
test datetime_utc_parse_millis  ... bench:         228 ns/iter (+/- 11)
test datetime_utc_parse_nanos   ... bench:         236 ns/iter (+/- 10)
test datetime_utc_parse_seconds ... bench:         204 ns/iter (+/- 18)
test rfc3339_humantime_millis   ... bench:          28 ns/iter (+/- 1)
test rfc3339_humantime_nanos    ... bench:          36 ns/iter (+/- 2)
test rfc3339_humantime_seconds  ... bench:          24 ns/iter (+/- 1)

test result: ok. 0 passed; 0 failed; 0 ignored; 6 measured; 0 filtered out

See serde-humantime for serde integration.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~46KB