Crates.io | system_tz |
lib.rs | system_tz |
version | 0.4.0 |
source | src |
created_at | 2023-04-11 09:52:25.501673 |
updated_at | 2023-04-11 19:06:14.243109 |
description | Current timezone from the operating system |
homepage | |
repository | https://github.com/b4D8/system_tz |
max_upload_size | |
id | 835914 |
size | 73,438 |
This utility crate provides a single trait SystemTz
which exposes the system_tz()
method allowing to get the timezone
from the operating system.
Should support the following operating system families: unix
, windows
and wasm
.
Effectively tested on:
Valid timezones are represented with chrono_tz::Tz
based on IANA Time Zone Database (Olson names).
On Microsoft Windows, because it uses of a special naming convention,
the method relies on WindowsZones
,
a dataset maintained by the Unicode Common Locale Data Repository (CLDR),
which is downloaded and built into a static global object during compilation.
Attention was given to provide safe implementation (no unwrap()
or expect()
)
but note that on windows target:
unsafe
is used by the fallback method because of windows
API.The crate provides a very basic binary which will print the system timezone on invokation.
Refer to the official documentation
for installing the cargo
package manager, and then run the following command
from a terminal:
$ cargo install system_tz
The interface doesn't require any argument.
$ tz
Europe/Paris
Contributions to the project are most welcome. In particular, please let us known whether it works on your device so we can improve the implementation and extend support.
Pull request imply agreement to the Developer's certificate of origin (DCO-1.1
).