You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
721 B

use time::Date;
use time::Month;
use time::Duration;
fn main() {
let d_begin = Date::from_calendar_date(1901, Month::January, 1).unwrap();
let d_end = Date::from_calendar_date(2000, Month::December, 31).unwrap();
let dt = Duration::DAY;
let mut day_count = 0u32;
let mut sundays_count = 0u32;
let mut di = d_begin.clone();
while di != d_end {
if di.weekday() == time::Weekday::Sunday {
if di.day() == 1 {
sundays_count += 1;
}
}
//println!("{}", di.weekday());
di = di.checked_add(dt).unwrap();
day_count += 1;
}
println!("day_count: {}", day_count);
println!("sundays count: {}", sundays_count);
}