Skip to content

Instantly share code, notes, and snippets.

@BenDavidAaron
Last active November 19, 2022 18:12
Show Gist options
  • Save BenDavidAaron/732a4240c2be090b10e6e5060a8b7d00 to your computer and use it in GitHub Desktop.
Save BenDavidAaron/732a4240c2be090b10e6e5060a8b7d00 to your computer and use it in GitHub Desktop.
Sdate in rust
extern crate chrono;
use chrono::{TimeZone, Utc};
fn count_days_since_sdate() -> u64 {
let utc = Utc;
let now = Utc::now();
let sept_date = utc
.datetime_from_str(&"Sept 01 00:00:01 1993", "%b %d %H:%M:%S %Y")
.unwrap();
let duration_since_sdate = now.signed_duration_since(sept_date);
duration_since_sdate.num_days().try_into().unwrap()
}
fn main() {
println!("Today is: Sept {} 1993", count_days_since_sdate())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment