Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Basic Date Parsing In Rust

rust
//! ```cargo
//! [dependencies]
//! chrono = "0.4.31"
//! ```

use chrono::prelude::*;

fn main() {
  let date_string = "2023-12-21 13:46:47";
  let hour = 3600;
  let tz = FixedOffset::west_opt(5 * hour).unwrap();
  let ndt = NaiveDateTime::parse_from_str(date_string, "%Y-%m-%d %H:%M:%S")
    .unwrap()
    .and_local_timezone(tz)
    .unwrap();
  println!("{}", ndt);
}
results start