1 stable release

3.0.0 Oct 3, 2024

#875 in Network programming


Used in 2 crates

AGPL-3.0-only

69KB
1.5K SLoC

Torrust Tracker Clock

A library to provide a working and mockable clock for the Torrust Tracker.

Documentation

Crate documentation.

License

The project is licensed under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE.


lib.rs:

Time related functions and types.

It's usually a good idea to control where the time comes from in an application so that it can be mocked for testing and it can be controlled in production so we get the intended behavior without relying on the specific time zone for the underlying system.

Clocks use the type DurationSinceUnixEpoch which is a std::time::Duration since the Unix Epoch (timestamp).

Local time:     lun 2023-03-27 16:12:00 WEST
Universal time: lun 2023-03-27 15:12:00 UTC
Time zone:      Atlantic/Canary (WEST, +0100)
Timestamp:      1679929914
Duration:       1679929914.10167426

NOTICE: internally the Duration is stores it's main unit as seconds in a u64 and it will overflow in 584.9 billion years.

NOTICE: the timestamp does not depend on the time zone. That gives you the ability to use the clock regardless of the underlying system time zone configuration. See Unix time Wikipedia entry.

Dependencies

~6–12MB
~140K SLoC