1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

Chrono update (#2397)

* limit day to last day of month if the month or year is changed

* update chrono to 0.4.23, switch to NaiveDate and remove use of deprecated functions.
This commit is contained in:
René Rössler
2022-12-06 11:42:53 +01:00
committed by GitHub
parent 9e3da91a59
commit c3932f7f7f
5 changed files with 21 additions and 22 deletions

View File

@@ -2,16 +2,16 @@ mod button;
mod popup;
pub use button::DatePickerButton;
use chrono::{Date, Datelike, Duration, NaiveDate, Utc, Weekday};
use chrono::{Datelike, Duration, NaiveDate, Weekday};
#[derive(Debug)]
struct Week {
number: u8,
days: Vec<Date<Utc>>,
days: Vec<NaiveDate>,
}
fn month_data(year: i32, month: u32) -> Vec<Week> {
let first = Date::from_utc(NaiveDate::from_ymd(year, month, 1), Utc);
let first = NaiveDate::from_ymd_opt(year, month, 1).expect("Could not create NaiveDate");
let mut start = first;
while start.weekday() != Weekday::Mon {
start = start.checked_sub_signed(Duration::days(1)).unwrap();