diff options
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/repetition.rs | 15 | 
1 files changed, 9 insertions, 6 deletions
| diff --git a/src/model/repetition.rs b/src/model/repetition.rs index 155545f..6151cbf 100644 --- a/src/model/repetition.rs +++ b/src/model/repetition.rs @@ -80,8 +80,9 @@ impl Repetition {                  Box::new(|d| first_weekday_of_month(next_month(d), weekday)),              ),              Frequency::Yearly => repeat( -                NaiveDate::from_ymd(event.year(), event.month(), event.day()), -                Box::new(|d| NaiveDate::from_ymd(d.year() + 1, d.month(), d.day())), +                // TODO: error handling +                NaiveDate::from_ymd_opt(event.year(), event.month(), event.day()).unwrap(), +                Box::new(|d| NaiveDate::from_ymd_opt(d.year() + 1, d.month(), d.day()).unwrap()),              ),          }      } @@ -97,14 +98,16 @@ impl Repetition {  }  fn first_weekday_of_month(date: NaiveDate, weekday: Weekday) -> NaiveDate { -    NaiveDate::from_weekday_of_month(date.year(), date.month(), weekday, 1) +    // TODO: error handling +    NaiveDate::from_weekday_of_month_opt(date.year(), date.month(), weekday, 1).unwrap()  }  fn next_month(date: NaiveDate) -> NaiveDate { +    // TODO: error handling      if date.month() == 12 { -        NaiveDate::from_ymd(date.year() + 1, 1, date.day()) +        NaiveDate::from_ymd_opt(date.year() + 1, 1, date.day()).unwrap()      } else { -        NaiveDate::from_ymd(date.year(), date.month() + 1, date.day()) +        NaiveDate::from_ymd_opt(date.year(), date.month() + 1, date.day()).unwrap()      }  } @@ -290,7 +293,7 @@ mod tests {      }      fn d(y: i32, m: u32, d: u32) -> NaiveDate { -        NaiveDate::from_ymd(y, m, d) +        NaiveDate::from_ymd_opt(y, m, d)      }      fn from_freq(frequency: Frequency) -> Repetition { | 
