-
Hi. |
Beta Was this translation helpful? Give feedback.
Answered by
Bas-Man
Feb 13, 2023
Replies: 1 comment 1 reply
-
The answer is to use So one can simply do use time::OffsetDateTime;
fn main() {
let date = OffsetDateTime::now_utc().date();
println!("{}", date);
let year = date.month();
let mon = date.month() as u8;
println!("{} {}", year, mon);
// try using the `time` crate here
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Bas-Man
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The answer is to use
as u8
because the Month enum has#[repr(u8)]
So one can simply do
Playground