diff options
author | Nora <nora.widdecke@tu-bs.de> | 2019-02-13 18:19:18 +0100 |
---|---|---|
committer | Nora <nora.widdecke@tu-bs.de> | 2019-02-13 18:19:18 +0100 |
commit | c705aff79c816ca73e1dca54fb9bb03cfd6be898 (patch) | |
tree | fd251c738f95ab445464e1a3e4f6d1b3a553c5af /src | |
parent | 0c08f7ff7ad127c05778322735fbac57da02625b (diff) |
add test for with_dtstart with timezone
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/new.rs | 1 | ||||
-rw-r--r-- | src/icalwrap/icalvcalendar.rs | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/actions/new.rs b/src/actions/new.rs index fdfeb65..8b196f6 100644 --- a/src/actions/new.rs +++ b/src/actions/new.rs @@ -176,6 +176,7 @@ mod integration { let from = EventProperties::parse_from("2017-07-14T17:45:00").unwrap(); let expected = IcalTime::floating_ymd(2017, 7, 14).and_hms(17, 45, 0); assert_eq!(expected, from); + assert_eq!("Europe/Berlin", from.get_timezone().unwrap().get_name()); } #[test] diff --git a/src/icalwrap/icalvcalendar.rs b/src/icalwrap/icalvcalendar.rs index cb9753b..2228503 100644 --- a/src/icalwrap/icalvcalendar.rs +++ b/src/icalwrap/icalvcalendar.rs @@ -368,6 +368,7 @@ impl Drop for IcalComponentOwner { mod tests { use super::*; use crate::testdata; + use chrono::{Local,TimeZone}; #[test] fn test_from_str_empty() { @@ -527,6 +528,21 @@ mod tests { } #[test] + fn test_with_dtstart_timezone() { + testdata::setup(); + let cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY, None).unwrap(); + + let local_date = Local.ymd(2018, 1, 1).and_hms(11, 30, 20); + let timestamp = IcalTime::from(local_date); + + let new_cal = cal.with_dtstart(×tamp); + + let event = new_cal.get_principal_event(); + assert_eq!(timestamp, event.get_dtstart().unwrap()); + assert_eq!("Europe/Berlin", event.get_dtstart().unwrap().get_timezone().unwrap().get_name()); + } + + #[test] fn test_with_internal_timestamp() { let cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY, None).unwrap(); |