mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 02:22:21 +00:00
reccurence expansion: Match datetime types
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user