reccurence expansion: Match datetime types

This commit is contained in:
Lennart
2025-06-10 17:56:56 +02:00
parent 32225bdda8
commit 3eeef18a14
3 changed files with 30 additions and 10 deletions

View File

@@ -190,6 +190,13 @@ impl CalDateTime {
}
}
pub fn format_date(&self) -> String {
match self {
Self::DateTime(datetime) => datetime.format(LOCAL_DATE).to_string(),
Self::Date(date, _) => date.format(LOCAL_DATE).to_string(),
}
}
pub fn date(&self) -> NaiveDate {
match self {
Self::DateTime(datetime) => datetime.date_naive(),
@@ -197,6 +204,10 @@ impl CalDateTime {
}
}
pub fn is_date(&self) -> bool {
matches!(&self, Self::Date(_, _))
}
pub fn as_datetime(&self) -> Cow<DateTime<CalTimezone>> {
match self {
Self::DateTime(datetime) => Cow::Borrowed(datetime),