diff options
author | Joris | 2024-12-31 12:18:06 +0100 |
---|---|---|
committer | Joris | 2024-12-31 12:18:06 +0100 |
commit | 8a78d6fcb970d256f7645d6c0a6f02da987a2896 (patch) | |
tree | 84e8d970a5c31b62ef79c39d3e3370ea81ad61ac /src/gui | |
parent | 67da13d3cdadb6d613470c3089864d6cc6ac5ced (diff) |
Fix getting start of weekmain
The 1st week of the year can begin some days the year before.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/app.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/gui/app.rs b/src/gui/app.rs index 5469e53..76dff71 100644 --- a/src/gui/app.rs +++ b/src/gui/app.rs @@ -2,7 +2,7 @@ use gtk4 as gtk; use anyhow::Result; use async_channel::Sender; -use chrono::{Datelike, Duration, NaiveDate, Weekday}; +use chrono::{Datelike, Duration, NaiveDate}; use rusqlite::Connection; use std::rc::Rc; @@ -30,10 +30,7 @@ pub struct App { impl App { pub fn new(conn: Rc<Connection>, app: >k::Application, tx: Sender<Msg>) -> Result<Self> { let today = chrono::offset::Local::now().naive_local().date(); - // TODO: error handling - let start_date = - NaiveDate::from_isoywd_opt(today.year(), today.iso_week().week(), Weekday::Mon) - .unwrap(); + let start_date = today - Duration::days(today.weekday().num_days_from_monday().into()); let end_date = start_date + Duration::days(7 * 4 - 1); let events = db::events::list_non_recurring_between(&conn, start_date, end_date)?; |