diff options
author | Nora <nora.widdecke@tu-bs.de> | 2019-01-20 01:35:19 +0100 |
---|---|---|
committer | Nora <nora.widdecke@tu-bs.de> | 2019-01-20 01:35:19 +0100 |
commit | 28f473d33db6bdc3422c7803943b0d51a3d78c80 (patch) | |
tree | 8693a9d194f9be300ac646ec19bbc8c17e605c74 /src/icalwrap | |
parent | 08e6080ef8c947d46139d9254113c055cb184380 (diff) |
icalvcalendar: replace magic strings by constants
Diffstat (limited to 'src/icalwrap')
-rw-r--r-- | src/icalwrap/icalvcalendar.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/icalwrap/icalvcalendar.rs b/src/icalwrap/icalvcalendar.rs index e1c8e82..dee5154 100644 --- a/src/icalwrap/icalvcalendar.rs +++ b/src/icalwrap/icalvcalendar.rs @@ -177,7 +177,9 @@ impl IcalVCalendar { let event = self.get_principal_event(); unsafe { let now_icaltime = IcalTime::now(); - if let Some(prop) = event.get_property_by_name("LAST-MODIFIED") { + + let last_modified_kind = ical::icalproperty_kind_ICAL_LASTMODIFIED_PROPERTY; + if let Some(prop) = event.get_property(last_modified_kind) { ical::icalproperty_set_lastmodified(prop.ptr, *now_icaltime); } else { let prop_lastmod = ical::icalproperty_new_lastmodified(*now_icaltime); @@ -412,7 +414,9 @@ mod tests { let mut cal = IcalVCalendar::from_str(testdata::TEST_EVENT_MULTIDAY, None).unwrap(); cal = cal.with_dtstamp_now(); let event = cal.get_principal_event(); - let now_dtstamp = event.get_property_by_name("DTSTAMP").unwrap().get_value(); + + let dtstamp_prop = ical::icalproperty_kind_ICAL_DTSTAMP_PROPERTY; + let now_dtstamp = event.get_property(dtstamp_prop).unwrap().get_value(); assert_eq!(now_dtstamp, "20130101T010203Z") } @@ -464,7 +468,9 @@ mod tests { let new_cal = cal.with_last_modified_now(); let event = new_cal.get_principal_event(); - assert_eq!("20130101T010203Z", event.get_property_by_name("LAST-MODIFIED").unwrap().get_value()); + + let last_modified_kind = ical::icalproperty_kind_ICAL_LASTMODIFIED_PROPERTY; + assert_eq!("20130101T010203Z", event.get_property(last_modified_kind).unwrap().get_value()); } #[test] @@ -473,7 +479,9 @@ mod tests { let new_cal = cal.with_last_modified_now(); let event = new_cal.get_principal_event(); - assert_eq!("20130101T010203Z", event.get_property_by_name("LAST-MODIFIED").unwrap().get_value()); + + let last_modified_kind = ical::icalproperty_kind_ICAL_LASTMODIFIED_PROPERTY; + assert_eq!("20130101T010203Z", event.get_property(last_modified_kind).unwrap().get_value()); } #[test] |