You are viewing a single comment's thread. Return to all comments →
rust
fn day_of_programmer(year: i32) -> String { let mut days_of_month: [usize; 12] = [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; days_of_month[1] = match year { 1700..=1917 => if year % 4 == 0 { 29 } else { 28 }, // julian 1919..=2700 => if year % 400 == 0 || (year % 4 == 0 && year % 100 != 0) { 29 } else { 28 }, // gregorian 1918 => 15, // transition year _ => panic!("time traveler error") }; let mut days = 256usize; let mut i = 0usize; while days > days_of_month[i] { days -= days_of_month[i]; i += 1; } format!("{:02}.{:02}.{year}", days, i+1) }
Seems like cookies are disabled on this browser, please enable them to open this website
Day of the Programmer
You are viewing a single comment's thread. Return to all comments →
rust