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

#544 in Date and time

Download history 296/week @ 2025-10-05 354/week @ 2025-10-12 290/week @ 2025-10-19 325/week @ 2025-10-26 520/week @ 2025-11-02 350/week @ 2025-11-09 311/week @ 2025-11-16 832/week @ 2025-11-23 417/week @ 2025-11-30 599/week @ 2025-12-07 210/week @ 2025-12-14 201/week @ 2025-12-21 223/week @ 2025-12-28 208/week @ 2026-01-04 114/week @ 2026-01-11 170/week @ 2026-01-18

737 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

~1.7–6.5MB
~141K SLoC