4 releases

0.2.1 Dec 17, 2020
0.2.0 Dec 21, 2018
0.1.1 Dec 20, 2018
0.1.0 Dec 20, 2018

#345 in Date and time

Download history 73/week @ 2024-11-17 129/week @ 2024-11-24 178/week @ 2024-12-01 321/week @ 2024-12-08 305/week @ 2024-12-15 59/week @ 2024-12-22 131/week @ 2024-12-29 232/week @ 2025-01-05 322/week @ 2025-01-12 332/week @ 2025-01-19 167/week @ 2025-01-26 328/week @ 2025-02-02 353/week @ 2025-02-09 214/week @ 2025-02-16 294/week @ 2025-02-23 141/week @ 2025-03-02

1,068 downloads per month
Used in 4 crates (via ckb-extension-fee-estimat…)

MIT license

14KB
148 lines

faketime

Build Status Build status

Provides a method unix_time which returns elapsed time since UNIX EPOCH. The returned time can be faked in each thread separately.

Documentation

Quick Start

Add faketime as dependency and use faketime::unix_time or faketime::unix_time_as_millis to get current time.

To fake time in test:

  • Use faketime::millis_tempfile to create a temp timestamp file.
  • Enable faketime via faketime::enable in current thread.

To fake time in child threads:

  • Use faketime::millis_tempfile to create a temp timestamp file.
  • Set child thread name to FAKETIME=PATH, where PATH is the path to the timestamp file.

To fake time of the generated binary, set the environment variable

echo 123456 > /tmp/faketime
FAKETIME=/tmp/faketime path/to/binary

Dependencies

~2–11MB
~133K SLoC