Crates.io | utcnow |
lib.rs | utcnow |
version | |
source | src |
created_at | 2022-07-23 03:27:28.847324 |
updated_at | 2024-12-12 02:20:34.671963 |
description | Get the current unixtime in a no-std context |
homepage | |
repository | https://github.com/Kijewski/utcnow |
max_upload_size | |
id | 631266 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This library solves one question, and one question only: What's the time?
In UTC, and
according to the clock of the PC, tablet, toaster … the library runs on,
expressed as seconds + nanoseconds since 1970-01-01
.
let now = utcnow().unwrap();
let seconds = now.as_secs();
let nanos = now.subsec_nanos();
For many target platforms this call cannot fail.
If this is true for the current target, then the constant INFALLIBLE
will be true
.
If the target platform is not supported, then utcnow()
will always return an error instead of failing to compile.
Use the library with default-features = false
and without the feature fallback
to get a compile-time error instead.
The feature std
(enabled by default) is only needed if you need the Error
type to implement std::error::Error
.
If you have successfully tested one of the untested targets, then please tell me. And if not, then even more so!
If you know how to implement another target, then please open a pull request.
Supported and tested:
(Probably) supported, but not actually tested:
Increasing the msrv for tier-2 or lower platforms will not be indicated as a breaking change to the semver version.
utcnow
has the following optional features:
serde
, which implements serde::Deserialize
and serde::Serialize
for UtcTime
.
arbitrary
, which implements the arbitrary::Arbitrary
trait for UtcTime
.
proptest
, which implements the proptest::arbitrary::Arbitrary
trait for UtcTime
.
quickcheck
, which implements the quickcheck::Arbitrary
trait for UtcTime
.
rkyv
, which implements the rkyv::Archive
,
rkyv::Serialize
,
and rkyv::Deserialize
for UtcTime
.
castaway
, which implements the castaway::LifetimeFree
trait for UtcTime
.