diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/app.rs | 9 | ||||
-rw-r--r-- | src/gui/form/mod.rs | 8 | ||||
-rw-r--r-- | src/gui/form/repetition.rs | 2 |
3 files changed, 8 insertions, 11 deletions
diff --git a/src/gui/app.rs b/src/gui/app.rs index 5469e53..826f051 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,16 +30,13 @@ 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)?; let recurring_events = db::events::list_recurring(&conn)?; let categories = db::categories::list(&conn)?; - let default_color = db::event_color::get_default_color(&conn)?; + let default_color = db::event_colors::get_default_color(&conn)?; let calendar = calendar::create( tx.clone(), diff --git a/src/gui/form/mod.rs b/src/gui/form/mod.rs index 197bc14..a14fb82 100644 --- a/src/gui/form/mod.rs +++ b/src/gui/form/mod.rs @@ -256,10 +256,10 @@ pub async fn show(app: &App, target: Target) { match event::validate( id, - date.buffer().text().to_string(), - name.buffer().text().to_string(), - start.buffer().text().to_string(), - end.buffer().text().to_string(), + &date.buffer().text(), + &name.buffer().text(), + &start.buffer().text(), + &end.buffer().text(), repetition, category, ) { diff --git a/src/gui/form/repetition.rs b/src/gui/form/repetition.rs index 4ed9803..6e7a13f 100644 --- a/src/gui/form/repetition.rs +++ b/src/gui/form/repetition.rs @@ -195,7 +195,7 @@ pub fn validate( // Check until let until = (if frequency.is_some() { - match validation::non_empty(model.until.buffer().text().to_string()) { + match validation::non_empty(&model.until.buffer().text()) { Some(until) => match NaiveDate::parse_from_str(&until, event::DATE_FORMAT) { Ok(until) => Ok(Some(until)), Err(_) => Err(format!("Can’t parse date from {}", until)), |