export: Include vtimezones

fixes #112
This commit is contained in:
Lennart
2025-08-22 21:32:34 +02:00
parent 9decef093d
commit 9c114dc204
2 changed files with 20 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ use chrono::DateTime;
use chrono::Utc;
use derive_more::Display;
use ical::generator::{Emitter, IcalCalendar};
use ical::parser::ical::component::IcalTimeZone;
use ical::property::Property;
use serde::Deserialize;
use serde::Serialize;
@@ -71,6 +72,7 @@ pub struct CalendarObject {
data: CalendarObjectComponent,
properties: Vec<Property>,
ics: String,
vtimezones: HashMap<String, IcalTimeZone>,
}
impl CalendarObject {
@@ -102,6 +104,13 @@ impl CalendarObject {
.map(|timezone| (timezone.get_tzid().to_owned(), (&timezone).try_into().ok()))
.collect();
let vtimezones = cal
.timezones
.clone()
.into_iter()
.map(|timezone| (timezone.get_tzid().to_owned(), timezone))
.collect();
let data = if let Some(event) = cal.events.into_iter().next() {
CalendarObjectComponent::Event(EventObject { event, timezones })
} else if let Some(todo) = cal.todos.into_iter().next() {
@@ -118,9 +127,14 @@ impl CalendarObject {
data,
properties: cal.properties,
ics,
vtimezones,
})
}
pub fn get_vtimezones(&self) -> &HashMap<String, IcalTimeZone> {
&self.vtimezones
}
pub fn get_data(&self) -> &CalendarObjectComponent {
&self.data
}