https://github.com/nervosnetwork/faketime
Provides a method unix_time which returns elapsed time since UNIX EPOCH. The returned time can be faked in each thread separately.
https://github.com/nervosnetwork/faketime
rust test time
Last synced: about 1 year ago
JSON representation
Provides a method unix_time which returns elapsed time since UNIX EPOCH. The returned time can be faked in each thread separately.
- Host: GitHub
- URL: https://github.com/nervosnetwork/faketime
- Owner: nervosnetwork
- License: mit
- Created: 2018-12-20T15:41:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-19T02:12:22.000Z (about 5 years ago)
- Last Synced: 2025-07-09T07:04:29.655Z (about 1 year ago)
- Topics: rust, test, time
- Language: Rust
- Homepage:
- Size: 27.3 KB
- Stars: 11
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: COPYING
Awesome Lists containing this project
README
# faketime
[](https://travis-ci.com/nervosnetwork/faketime)
[](https://ci.appveyor.com/project/doitian/faketime)
Provides a method `unix_time` which returns elapsed time since _UNIX EPOCH_.
The returned time can be faked in each thread separately.
[Documentation](https://docs.rs/faketime)
## 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
```