提供人性化时间格式化的支持。 | A Rust library that provides support for human-readable time formatting.
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 6 年前 | ||
| 5 年前 | ||
| 10 年前 | ||
| 5 年前 | ||
| 7 个月前 | ||
| 5 年前 | ||
| 10 年前 | ||
| 8 年前 | ||
| 1 年前 | ||
| 6 年前 | ||
| 8 年前 | ||
| 7 个月前 | ||
| 6 年前 |
以下内容由 AI 翻译,如有问题请 点此提交 issue 反馈
人类时间
状态:稳定
功能特点:
- 支持自由格式的时长解析,例如
15天 2分钟 2秒 - 支持类似格式的时长格式化,如
2年 2分钟 12微秒 - 支持解析和格式化遵循
rfc3339标准的时间戳:2018-01-01T12:53:00Z - 支持解析较为宽松格式的时间戳:
2018-01-01 12:53:00
时间戳的解析和格式化速度极快,因为其格式基本上是固定的。
以下是一些微基准测试结果:
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
请参阅 humantime-serde 以获取 serde 集成(之前的包 serde-humantime 看起来已经不再维护)。
许可
本软件遵循以下任一许可协议:
- Apache License, Version 2.0(可参见 ./LICENSE-APACHE 或 http://www.apache.org/licenses/LICENSE-2.0)
- MIT license(可参见 ./LICENSE-MIT 或 http://opensource.org/licenses/MIT)
您可按需选择。
贡献
除非您明确声明 otherwise,否则您有意提交以包含在作品中的任何贡献,如 Apache-2.0 许可中定义,应视为按照上述双重许可,不附加任何额外条款或条件。