diff --git a/src/components/date_time.rs b/src/components/date_time.rs index 0ecb569..b45bd33 100644 --- a/src/components/date_time.rs +++ b/src/components/date_time.rs @@ -281,6 +281,17 @@ pub fn with_timezone( .into() } +impl From for NaiveDate { + fn from(dt: DatePerhapsTime) -> Self { + match dt { + DatePerhapsTime::Date(date) => date, + DatePerhapsTime::DateTime(CalendarDateTime::Floating(date_time)) => date_time.date(), + DatePerhapsTime::DateTime(CalendarDateTime::Utc(date_time)) => date_time.date_naive(), + DatePerhapsTime::DateTime(CalendarDateTime::WithTimezone { date_time, tzid: _ }) => date_time.date(), + } + } +} + impl From for DatePerhapsTime { fn from(dt: CalendarDateTime) -> Self { Self::DateTime(dt)