2 个不稳定版本
0.2.0 | 2023年4月9日 |
---|---|
0.1.2 | 2020年12月10日 |
#451 in 日期和时间
在 lb-rs 中使用
6KB
109 行
basic-human-duration
一个非常小的用于为人类格式化持续时间的 crate。
与原始 仓库... 相比...
- 支持月份
- 调整了被认为是 "刚刚" 的阈值(之前是 <60 分钟,现在是 <60 秒)
- 其他一些小的调整
示例
use basic_human_duration::ChronoHumanDuration;
use chrono::Duration;
let d = Duration::weeks(2) + Duration::days(3);
assert_eq!(d.format_human().to_string(), "2 weeks ago");
let d = Duration::seconds(20);
assert_eq!(d.format_human().to_string(), "just now");
依赖项
~740KB
~13K SLoC