2 个版本
| 0.1.1 | 2024年7月17日 |
|---|---|
| 0.1.0 | 2024年7月17日 |
#239 在 日期和时间 分类中
每月 314 次下载
28KB
58 代码行
Clockabilly

一个用于在测试中模拟时间的简单 trait 包装器,针对 chrono。
用法
任何需要模拟时间的位置,都需要传递一个 Clockable 接口。在您的“真实”代码中,可以使用 UtcClock,而在您的测试代码中,可以使用 MockUtcClock(您需要包含 mock 功能)。请参阅 basic 示例以获取示例。
> cargo run --example basic --features=mock
Compiling clockabilly v0.0.0 (/build/src/clockabilly)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s
Running `target/debug/examples/basic`
2024-07-17T17:41:02.369894602Z
1970-01-01T00:00:10Z
为了“简单”,此库导出了 chrono 的所有内容。
依赖关系
~1MB
~18K SLoC