1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -04:00

Move all crates into a crates directory (#1940)

This commit is contained in:
Emil Ernerfeldt
2022-08-20 10:41:49 +02:00
committed by GitHub
parent 5c63648c02
commit 041f2e64ba
260 changed files with 59 additions and 57 deletions

View File

@@ -0,0 +1,34 @@
mod button;
mod popup;
pub use button::DatePickerButton;
use chrono::{Date, Datelike, Duration, NaiveDate, Utc, Weekday};
#[derive(Debug)]
struct Week {
number: u8,
days: Vec<Date<Utc>>,
}
fn month_data(year: i32, month: u32) -> Vec<Week> {
let first = Date::from_utc(NaiveDate::from_ymd(year, month, 1), Utc);
let mut start = first;
while start.weekday() != Weekday::Mon {
start = start.checked_sub_signed(Duration::days(1)).unwrap();
}
let mut weeks = vec![];
let mut week = vec![];
while start < first || start.month() == first.month() || start.weekday() != Weekday::Mon {
week.push(start);
if start.weekday() == Weekday::Sun {
weeks.push(Week {
number: start.iso_week().week() as u8,
days: week.drain(..).collect(),
});
}
start = start.checked_add_signed(Duration::days(1)).unwrap();
}
weeks
}