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

#574 in Unix APIs

Download history 7/week @ 2023-12-18 25/week @ 2024-01-08 1/week @ 2024-01-22 67/week @ 2024-01-29 20/week @ 2024-02-05 24/week @ 2024-02-12 19/week @ 2024-02-19 16/week @ 2024-02-26 49/week @ 2024-03-04 48/week @ 2024-03-11 64/week @ 2024-03-18 29/week @ 2024-03-25 122/week @ 2024-04-01

267 downloads per month
Used in otp2

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.1–1.7MB
~41K SLoC