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

#283 in Date and time

Download history 207/week @ 2024-01-04 290/week @ 2024-01-11 310/week @ 2024-01-18 327/week @ 2024-01-25 227/week @ 2024-02-01 288/week @ 2024-02-08 243/week @ 2024-02-15 268/week @ 2024-02-22 325/week @ 2024-02-29 324/week @ 2024-03-07 240/week @ 2024-03-14 257/week @ 2024-03-21 262/week @ 2024-03-28 205/week @ 2024-04-04 245/week @ 2024-04-11 186/week @ 2024-04-18

950 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
~115K SLoC