summaryrefslogtreecommitdiffstats
path: root/src/icalwrap
diff options
context:
space:
mode:
authorVincent Breitmoser <look@my.amazin.horse>2019-01-12 15:38:57 +0100
committerVincent Breitmoser <look@my.amazin.horse>2019-01-12 16:33:39 +0100
commitc61a8075a98c4674694f3ab25f15cca54f9958f8 (patch)
tree7ddb912ebc4460f25f130e9824181c5121734ad0 /src/icalwrap
parent5216a30ac92716aa16b8760bd9048820a7466f33 (diff)
use Local for instance timestamps instead of Utc
Diffstat (limited to 'src/icalwrap')
-rw-r--r--src/icalwrap/icalvcalendar.rs10
-rw-r--r--src/icalwrap/icalvevent.rs8
2 files changed, 10 insertions, 8 deletions
diff --git a/src/icalwrap/icalvcalendar.rs b/src/icalwrap/icalvcalendar.rs
index 19c182c..dd6a5af 100644
--- a/src/icalwrap/icalvcalendar.rs
+++ b/src/icalwrap/icalvcalendar.rs
@@ -1,4 +1,4 @@
-use chrono::{DateTime, Utc};
+use chrono::{DateTime, Local};
use std::ffi::{CStr, CString};
use std::path::{PathBuf,Path};
use std::rc::Rc;
@@ -10,7 +10,7 @@ use ical;
pub struct IcalVCalendar {
comp: Rc<IcalComponentOwner>,
path: Option<PathBuf>,
- instance_timestamp: Option<DateTime<Utc>>,
+ instance_timestamp: Option<DateTime<Local>>,
}
pub struct IcalEventIter<'a> {
@@ -57,7 +57,7 @@ impl IcalVCalendar {
}
}
- pub fn with_internal_timestamp(mut self, datetime: DateTime<Utc>) -> IcalVCalendar {
+ pub fn with_internal_timestamp(mut self, datetime: DateTime<Local>) -> IcalVCalendar {
self.instance_timestamp = Some(datetime);
self
}
@@ -321,7 +321,7 @@ impl Drop for IcalComponentOwner {
mod tests {
use super::*;
use testdata;
- use chrono::{Local, TimeZone};
+ use chrono::{Utc, Local, TimeZone};
#[test]
fn test_from_str_empty() {
@@ -415,7 +415,7 @@ mod tests {
fn test_with_internal_timestamp() {
let cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY, None).unwrap();
- let timestamp = Utc.ymd(2018, 1, 1).and_hms(11, 30, 20);
+ let timestamp = Local.ymd(2018, 1, 1).and_hms(11, 30, 20);
let new_cal = cal.with_internal_timestamp(timestamp);
let event = new_cal.get_principal_event();
diff --git a/src/icalwrap/icalvevent.rs b/src/icalwrap/icalvevent.rs
index d51003f..278d737 100644
--- a/src/icalwrap/icalvevent.rs
+++ b/src/icalwrap/icalvevent.rs
@@ -8,7 +8,7 @@ use ical;
pub struct IcalVEvent {
ptr: *mut ical::icalcomponent,
parent: Option<IcalVCalendar>,
- instance_timestamp: Option<DateTime<Utc>>,
+ instance_timestamp: Option<DateTime<Local>>,
}
impl Drop for IcalVEvent {
@@ -123,7 +123,7 @@ impl IcalVEvent {
result
}
- pub fn with_internal_timestamp(&self, datetime: DateTime<Utc>) -> IcalVEvent {
+ pub fn with_internal_timestamp(&self, datetime: DateTime<Local>) -> IcalVEvent {
IcalVEvent {
ptr: self.ptr,
parent: self.parent.as_ref().map(|parent| parent.shallow_copy()),
@@ -132,7 +132,9 @@ impl IcalVEvent {
}
pub fn get_recur_instances(&self) -> impl Iterator<Item = IcalVEvent> + '_ {
- self.get_recur_datetimes().into_iter().map(move |rec| self.with_internal_timestamp(rec))
+ self.get_recur_datetimes().into_iter()
+ .map(|recur_utc| recur_utc.with_timezone(&Local))
+ .map(move |recur_local| self.with_internal_timestamp(recur_local))
}
pub fn get_parent(&self) -> Option<&IcalVCalendar> {