4 个版本

0.2.3 2022年2月23日
0.2.2 2022年2月13日
0.2.1 2022年2月12日
0.2.0 2022年2月5日
0.1.0 2022年2月4日

#255日期和时间

Download history 30/week @ 2024-04-20 9/week @ 2024-04-27 1/week @ 2024-05-11 7/week @ 2024-06-01 4/week @ 2024-06-08 4/week @ 2024-06-15 3/week @ 2024-06-22 4/week @ 2024-06-29 1232/week @ 2024-07-06 120/week @ 2024-07-13 2/week @ 2024-07-20 1/week @ 2024-07-27 23/week @ 2024-08-03

209 每月下载量
用于 roomor

MIT 许可证

115KB
3K SLoC

timediff

状态:稳定

文档 | Github | Crate

特性

  • 解析并打印可读的相对时间差。
  • std::time::Duration 解析为可读的相对时间差字符串。
  • 解析结果基于在 Day.js 中定义的区间

以下是一些持续时间及其对应的字符串输出的示例(来自测试输出),使用默认选项

-864000h   100 years ago
-172800h   20 years ago
-17280h    2 years ago
-8640h     a year ago
-7200h1m   a year ago
-7200h     10 months ago
-6480h     9 months ago
-1920h     3 months ago
-1104h     2 months ago
-1080h     a month ago
-624h      a month ago
-600h      25 days ago
-240h      10 days ago
-36h       2 days ago
-24h       a day ago
-22h       a day ago
-21h30m    a day ago
-21h       21 hours ago
-20h       20 hours ago
-2h        2 hours ago
-90m       2 hours ago
-89m       an hour ago
-80m       an hour ago
-1h        an hour ago
-60m       an hour ago
-45m       an hour ago
-44m       44 minutes ago
-10m       10 minutes ago
-2m        2 minutes ago
-90s       2 minutes ago
-89s       a minute ago
-45s       a minute ago
-44s       a few seconds ago
-10s       a few seconds ago
10s        in a few seconds
44s        in a few seconds
45s        in a minute
89s        in a minute
90s        in 2 minutes
2m         in 2 minutes
10m        in 10 minutes
44m        in 44 minutes
45m        in an hour
60m        in an hour
1h         in an hour
80m        in an hour
89m        in an hour
90m        in 2 hours
2h         in 2 hours
20h        in 20 hours
21h        in 21 hours
21h30m     in a day
22h        in a day
24h        in a day
36h        in 2 days
240h       in 10 days
600h       in 25 days
624h       in a month
1080h      in a month
1104h      in 2 months
1920h      in 3 months
6480h      in 9 months
7200h      in 10 months
7200h1m    in a year
8640h      in a year
17280h     in 2 years
172800h    in 20 years
864000h    in 100 years

许可证

本软件包采用 MIT 许可证。有关详细信息,请参阅 LICENSE

鸣谢

依赖关系

~43KB