2

I have a code https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cde949e0a59445ee9beb01964a3ab903

use chrono::Datelike;
use chrono::Duration;
use chrono::Local;

fn main() {
    let now = Local::now();
    println!("######################################");
    for day in 0..31 {
        println!(
            "{}",
            (now + Duration::days(7 - now.weekday().num_days_from_monday() as i64 + day))
                .format("%Y-%m-%d %A")
        );
        println!("\ntest\n\n########################");
    }
}

Q: Where I need the weekdays to be in ex.: "HU" language and not in the English "Monday, Tuesday", etc.

I already tried based on https://docs.rs/chrono/0.4.19/chrono/ the ", Locale::hu_HU)" but always failed so far, can you pls help on this?

E_net4
  • 27,810
  • 13
  • 101
  • 139
jim7475
  • 43
  • 4

1 Answers1

2

I think you need the feature unstable-locales for this. See here for the usage of format_localized.

phimuemue
  • 34,669
  • 9
  • 84
  • 115
  • I tried, thanks! https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f30ea7d0e0b7e5f1ee852d7b53f93aee so far it gaved 4 | use chrono::unstable-locales; | ^ expected one of `::`, `;`, or `as` – jim7475 Oct 05 '21 at 07:07
  • @jim7475 Did you put `chrono { version = "0.4", features = ["unstable-locales"]` into your `Cargo.toml`? I think that's what's needed, not `use chrono::unstable-locales;` in `main.rs`. – phimuemue Oct 05 '21 at 12:14