зеркало из https://github.com/mozilla/pjs.git
Bug 390492 events with DURATION get serialized with DURATION and DTEND; r=sebo
This commit is contained in:
Родитель
94904b36d0
Коммит
06b9dd863b
|
@ -209,29 +209,7 @@ calEvent.prototype = {
|
|||
this.mapPropsFromICS(event, this.icsEventPropMap);
|
||||
|
||||
this.importUnpromotedProperties(event, this.eventPromotedProps);
|
||||
|
||||
// If there is a duration set on the event, calculate the right
|
||||
// end time.
|
||||
// XXX This means that serializing later will loose the duration
|
||||
// information, to replace it with a dtend. bug 317786
|
||||
if (event.duration) {
|
||||
this.endDate = this.startDate.clone();
|
||||
this.endDate.addDuration(event.duration);
|
||||
}
|
||||
|
||||
// If endDate is still invalid neither a end time nor a duration is set
|
||||
// on the event. We have to set endDate ourselves.
|
||||
// If the start time is a date-time the event ends on the same calendar
|
||||
// date and time of day. If the start time is a date the events
|
||||
// non-inclusive end is the end of the calendar date.
|
||||
var endDate = this.endDate;
|
||||
if (!endDate || !endDate.isValid) {
|
||||
this.endDate = this.startDate.clone();
|
||||
if (this.startDate.isDate) {
|
||||
this.endDate.day += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Importing didn't really change anything
|
||||
this.mDirty = false;
|
||||
},
|
||||
|
@ -273,12 +251,40 @@ calEvent.prototype = {
|
|||
|
||||
get startDate() {
|
||||
return this.getProperty("DTSTART");
|
||||
},
|
||||
|
||||
mEndDate: undefined,
|
||||
get endDate() {
|
||||
var endDate = this.mEndDate;
|
||||
if (endDate === undefined) {
|
||||
endDate = this.getProperty("DTEND");
|
||||
if (!endDate) {
|
||||
endDate = this.startDate.clone();
|
||||
var dur = this.getProperty("DURATION");
|
||||
if (dur) {
|
||||
// If there is a duration set on the event, calculate the right end time.
|
||||
var icalDur = Components.classes["@mozilla.org/calendar/duration;1"]
|
||||
.createInstance(Components.interfaces.calIDuration);
|
||||
icalDur.icalString = dur;
|
||||
endDate.addDuration(icalDur);
|
||||
} else {
|
||||
// If the start time is a date-time the event ends on the same calendar
|
||||
// date and time of day. If the start time is a date the events
|
||||
// non-inclusive end is the end of the calendar date.
|
||||
if (endDate.isDate) {
|
||||
endDate.day += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mEndDate = endDate;
|
||||
}
|
||||
return endDate;
|
||||
},
|
||||
|
||||
set endDate(value) {
|
||||
this.deleteProperty("DURATION"); // setting endDate once removes DURATION
|
||||
this.setProperty("DTEND", value);
|
||||
return (this.mEndDate = value);
|
||||
}
|
||||
};
|
||||
|
||||
// var to avoid spurious errors when loaded as component during autoreg
|
||||
|
||||
var makeMemberAttr;
|
||||
if (makeMemberAttr) {
|
||||
makeMemberAttr(calEvent, "DTEND", null, "endDate", true);
|
||||
}
|
||||
|
|
|
@ -276,14 +276,41 @@ calTodo.prototype = {
|
|||
|
||||
get entryDate() {
|
||||
return this.getProperty("DTSTART");
|
||||
},
|
||||
|
||||
mDueDate: undefined,
|
||||
get dueDate() {
|
||||
var dueDate = this.mDueDate;
|
||||
if (dueDate === undefined) {
|
||||
dueDate = this.getProperty("DUE");
|
||||
if (!dueDate) {
|
||||
var entryDate = this.entryDate;
|
||||
var dur = this.getProperty("DURATION");
|
||||
if (entryDate && dur) {
|
||||
// If there is a duration set on the todo, calculate the right end time.
|
||||
dueDate = entryDate.clone();
|
||||
var icalDur = Components.classes["@mozilla.org/calendar/duration;1"]
|
||||
.createInstance(Components.interfaces.calIDuration);
|
||||
icalDur.icalString = dur;
|
||||
dueDate.addDuration(icalDur);
|
||||
}
|
||||
}
|
||||
this.mDueDate = dueDate;
|
||||
}
|
||||
return dueDate;
|
||||
},
|
||||
|
||||
set dueDate(value) {
|
||||
this.deleteProperty("DURATION"); // setting dueDate once removes DURATION
|
||||
this.setProperty("DUE", value);
|
||||
return (this.mDueDate = value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// var decl to prevent spurious error messages when loaded as component
|
||||
|
||||
var makeMemberAttr;
|
||||
if (makeMemberAttr) {
|
||||
makeMemberAttr(calTodo, "DUE", null, "dueDate", true);
|
||||
makeMemberAttr(calTodo, "COMPLETED", null, "completedDate", true);
|
||||
makeMemberAttr(calTodo, "PERCENT-COMPLETE", 0, "percentComplete", true);
|
||||
}
|
||||
|
|
|
@ -950,7 +950,7 @@ function checkIfInRange(item, rangeStart, rangeEnd, returnDtstartOrDue)
|
|||
var completedDate = item.completedDate;
|
||||
if (completedDate) {
|
||||
var queryStart = ensureDateTime(rangeStart);
|
||||
var completedDate = ensureDateTime(completedDate);
|
||||
completedDate = ensureDateTime(completedDate);
|
||||
return (!queryStart || completedDate.compare(queryStart) > 0);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1560,7 +1560,11 @@ calStorageCalendar.prototype = {
|
|||
|
||||
while (selectItem.step()) {
|
||||
row = selectItem.row;
|
||||
item.setProperty (row.key, row.value);
|
||||
var name = row.key;
|
||||
if (name != "DURATION") {
|
||||
// for events DTEND/DUE is enforced by calEvent/calTodo, so suppress DURATION:
|
||||
item.setProperty(name, row.value);
|
||||
}
|
||||
}
|
||||
selectItem.reset();
|
||||
}
|
||||
|
@ -1833,14 +1837,8 @@ calStorageCalendar.prototype = {
|
|||
var ip = this.mInsertEvent.params;
|
||||
this.setupItemBaseParams(item, olditem,ip);
|
||||
|
||||
var tmp;
|
||||
|
||||
tmp = item.getUnproxiedProperty("DTSTART");
|
||||
//if (tmp instanceof Components.interfaces.calIDateTime) {}
|
||||
this.setDateParamHelper(ip, "event_start", tmp);
|
||||
tmp = item.getUnproxiedProperty("DTEND");
|
||||
//if (tmp instanceof Components.interfaces.calIDateTime) {}
|
||||
this.setDateParamHelper(ip, "event_end", tmp);
|
||||
this.setDateParamHelper(ip, "event_start", item.startDate);
|
||||
this.setDateParamHelper(ip, "event_end", item.endDate);
|
||||
|
||||
if (item.startDate.isDate)
|
||||
flags |= CAL_ITEM_FLAG_EVENT_ALLDAY;
|
||||
|
@ -1855,8 +1853,8 @@ calStorageCalendar.prototype = {
|
|||
|
||||
this.setupItemBaseParams(item, olditem,ip);
|
||||
|
||||
this.setDateParamHelper(ip, "todo_entry", item.getUnproxiedProperty("DTSTART"));
|
||||
this.setDateParamHelper(ip, "todo_due", item.getUnproxiedProperty("DUE"));
|
||||
this.setDateParamHelper(ip, "todo_entry", item.entryDate);
|
||||
this.setDateParamHelper(ip, "todo_due", item.dueDate);
|
||||
this.setDateParamHelper(ip, "todo_completed", item.getUnproxiedProperty("COMPLETED"));
|
||||
|
||||
ip.todo_complete = item.getUnproxiedProperty("PERCENT-COMPLETED");
|
||||
|
|
Загрузка…
Ссылка в новой задаче