6 releases

0.1.5 Jul 8, 2021
0.1.4 Jul 6, 2021
0.1.3 Dec 17, 2020
0.1.2 Nov 26, 2020

#605 in Unix APIs

Download history 46/week @ 2024-07-27 17/week @ 2024-08-03 54/week @ 2024-08-10 52/week @ 2024-08-17 19/week @ 2024-08-24 13/week @ 2024-08-31 45/week @ 2024-09-07 21/week @ 2024-09-14 80/week @ 2024-09-21 42/week @ 2024-09-28 33/week @ 2024-10-05 42/week @ 2024-10-12 24/week @ 2024-10-19 13/week @ 2024-10-26 133/week @ 2024-11-02 146/week @ 2024-11-09

318 downloads per month
Used in 4 crates

MIT license

11KB
96 lines

unix-time

A minimalist Rust crate to play with UNIX epoch-based Instant.

Using it

Simply add this to your Cargo.toml:

[dependencies]
unix-time = "0.1"

You can then use the defined Instant using

use unix_time::Instant;
// Do whatever you want with Instant

lib.rs:

A minimal crate to play with Instant based on UNIX epoch.

The standard library provides Instant and Duration structures to measure elapsed time. This is fine for most use cases, but the Instant structure voluntary hides its implementation to keep its semantics. This crate exposes its time base to the UNIX Epoch (1st January 1970 at 0:00).

The exposed API tries to mimic as much as possible the std::time one for the related Instant structures, such that passing from these to the ones of this crate would be as seamless as possible (as it actually uses std::time under the hood).

This crate should only be used to compute local time. It is thus not appropriate for timezone computations, playing with dates,...

Dependencies

~1.5–2MB
~47K SLoC