czas

Crates.ioczas
lib.rsczas
version0.0.3
sourcesrc
created_at2023-11-11 13:25:17.076873
updated_at2023-11-11 23:08:04.651459
descriptionConvert timestamps into localized text
homepagehttps://github.com/calemroelofs/czas
repositoryhttps://github.com/calemroelofs/czas
max_upload_size
id1032040
size43,361
Calem Roelofs (CalemRoelofs)

documentation

README

Czas - Convert timestamps into localized text

Czas is a library for converting chrono timestamps into localized text.
For example, 2020-01-01 01:23:45 would be converted (in Polish) to pierwszego stycznia dwa tysiące dwudziestego roku o pierwszej dwadzieścia trzy i czterdzieści pięć sekundy.
The library provides the public ToLocalizedText trait, which can be implemented against any struct to provide your own translations in any language/format.
The library comes with one struct implementation of this trait, Czas, which supports localization in Polish.

Documentation

Crate documentation can be found on docs.rs

Usage

Library

Add czas as a dependency in your Cargo.toml:

[dependencies]
czas = "*"

Then use it in your code:

use chrono::prelude::*;
use czas::{Czas, ToLocalizedText};

fn main() {
    let timestamp = Local::now().naive_local();
    println!(
        "{}: {}",
        timestamp,
        Czas::from_naive_date_time(timestamp).unwrap()
    );
}

Binary

# Install locally from this repo
$ cargo install path .

# Or from crates.io directly
$ cargo install czas

# Then run it
$ czas-teraz
2023-11-11 14:33:50.152787900: jedenastego listopada dwa tysiące dwudziestego trzeciego roku o czternastej trzydzieści trzy i pięćdziesiąt sekundy  

Contributing

PRs are welcome!
If you wish to change something with the existing implementation or add a new localization, please consider opening an issue for discussion.

License

This project is licensed under either of

at your option.

Commit count: 18

cargo fmt