system_tz

Crates.iosystem_tz
lib.rssystem_tz
version0.4.0
sourcesrc
created_at2023-04-11 09:52:25.501673
updated_at2023-04-11 19:06:14.243109
descriptionCurrent timezone from the operating system
homepage
repositoryhttps://github.com/b4D8/system_tz
max_upload_size
id835914
size73,438
b4D8 (b4D8)

documentation

README

system_tz

Version Documentation License

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:

  • 2023-04-11: Debian GNU/Linux 11 (bullseye)
  • 2023-04-11: Microsoft Windows 11
  • ...

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.

Safety

Attention was given to provide safe implementation (no unwrap() or expect()) but note that on windows target:

  • the build script is faillible (it is designed to panic on error)
  • 1 unsafe is used by the fallback method because of windows API.

Command-line interface

The crate provides a very basic binary which will print the system timezone on invokation.

Installation

Refer to the official documentation for installing the cargo package manager, and then run the following command from a terminal:

$ cargo install system_tz

Usage

The interface doesn't require any argument.

$ tz
Europe/Paris

Contribute

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).

Credits

Commit count: 9

cargo fmt