Fix
bug 873630 - Merge "Improve ICAL.Event time handling interface to also handle times and new properties" from upstream.,a=philipp
--- a/calendar/base/modules/ical.js
+++ b/calendar/base/modules/ical.js
@@ -6483,43 +6483,36 @@ ICAL.Event = (function() {
* TODO: this method handles the case where we are switching
* from a known timezone to an implied timezone (one without TZID).
* This does _not_ handle the case of moving between a known
* (by TimezoneService) timezone to an unknown timezone...
*
* We will not add/remove/update the VTIMEZONE subcomponents
* leading to invalid ICAL data...
*/
- _setTime: function(name, value) {
- var currentProp = this.component.getFirstProperty(name);
- var currentValue;
-
- if (currentProp && (currentValue = currentProp.getFirstValue())) {
- var newTzid = value.zone.tzid;
- var currentTzid = currentProp.getParameter('tzid');
-
- if (currentTzid !== newTzid) {
- /**
- * Both the localTimezone and the utcTimezone avoid TZID.
- * We must remove the tzid param in these cases otherwise
- * the time is either wrong or invalid.
- */
- if (
- value.zone === ICAL.Timezone.localTimezone ||
- value.zone === ICAL.Timezone.utcTimezone
- ) {
- currentProp.removeParameter('tzid');
- } else {
- // for the case where we are switching between to timezones.
- currentProp.setParameter('tzid', newTzid);
- }
- }
- }
-
- this._setProp(name, value);
+ _setTime: function(propName, time) {
+ var prop = this.component.getFirstProperty(propName);
+
+ if (!prop) {
+ prop = new ICAL.Property(propName);
+ this.component.addProperty(prop);
+ }
+
+ // utc and local don't get a tzid
+ if (
+ time.zone === ICAL.Timezone.localTimezone ||
+ time.zone === ICAL.Timezone.utcTimezone
+ ) {
+ // remove the tzid
+ prop.removeParameter('tzid');
+ } else {
+ prop.setParameter('tzid', time.zone.tzid);
+ }
+
+ prop.setValue(time);
},
_setProp: function(name, value) {
this.component.updatePropertyWithValue(name, value);
},
_firstProp: function(name) {
return this.component.getFirstPropertyValue(name);