Skip to content

Instantly share code, notes, and snippets.

@qolop
Created May 23, 2016 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qolop/8a721d9ac8217a378c3fc3ec817cc8d7 to your computer and use it in GitHub Desktop.
Save qolop/8a721d9ac8217a378c3fc3ec817cc8d7 to your computer and use it in GitHub Desktop.
Get the name of the current day in Rust.
extern crate time;
fn main() {
let t = time::now();
match t.tm_wday {
0 => println!("Sunday"),
1 => println!("Monday"),
2 => println!("Tuesday"),
3 => println!("Wednesday"),
4 => println!("Thursday"),
5 => println!("Friday"),
6 => println!("Saturday"),
_ => panic!("Erroneous value: {}", t.tm_wday),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment