Convert A UTC DateTime To A Specific Timezone In Rust
```cargo
[dependencies]
chrono = "0.4.39"
```
use chrono::{FixedOffset, NaiveDate};
fn main() {
let utc_year = 2025;
let utc_month = 1;
let utc_day = 1;
let utc_hour = 0;
let utc_min = 0;
let utc_sec = 0;
let offset_for_tz = -5;
let utc_dt = NaiveDate::from_ymd_opt(utc_year, utc_month, utc_day)
.unwrap()
.and_hms_opt(utc_hour, utc_min, utc_sec)
.unwrap()
.and_utc();
let tz_offset = FixedOffset::east_opt(offset_for_tz* 3600).unwrap();
let adjusted_dt = utc_dt.with_timezone(&tz_offset);
println!("{}", utc_dt);
println!("{}", adjusted_dt);
}
2025-01-01 00:00:00 UTC
2024-12-31 19:00:00 -05:00