Fix bug 428715 - Between 23:00 and 00:00, the default event start date is 00:00 of the next day. r=mschroeder
git-svn-id: svn://10.0.0.236/trunk@251341 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
a50ac7b611
commit
693723e93d
@ -389,7 +389,7 @@ function deleteItem(aItem, aMoveSelection) {
|
||||
agendaListbox.isSameEvent =
|
||||
function isSameEvent(aItem, aCompItem) {
|
||||
return ((aItem.id == aCompItem.id) &&
|
||||
(calGetStartDate(aItem).compare(calGetStartDate(aCompItem)) == 0));
|
||||
(aItem[calGetStartDateProp(aItem)].compare(aCompItem[calGetStartDateProp(aCompItem)]) == 0));
|
||||
}
|
||||
|
||||
agendaListbox.isEventSelected =
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
-
|
||||
- Contributor(s):
|
||||
- Berend Cornelius <berend.cornelius@sun.com>
|
||||
- Philipp Kewisch <mozilla@kewis.ch>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -177,7 +178,7 @@
|
||||
var dateFormatter = Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
|
||||
.getService(Components.interfaces.calIDateTimeFormatter);
|
||||
var duration = "";
|
||||
var start = calGetStartDate(item).getInTimezone(calendarDefaultTimezone());
|
||||
var start = item[calGetStartDateProp(item)].getInTimezone(calendarDefaultTimezone());
|
||||
if (longFormat) {
|
||||
duration = dateFormatter.formatDateTime(start);
|
||||
} else {
|
||||
|
||||
@ -42,20 +42,7 @@ var itemConversion = {
|
||||
aItem.calendar = getSelectedCalendar();
|
||||
aItem.title = aMessage.mime2DecodedSubject;
|
||||
|
||||
// The time for the event should default to the next full hour
|
||||
if (isEvent(aItem)) {
|
||||
aItem.startDate = now();
|
||||
aItem.startDate.second = 0;
|
||||
aItem.startDate.minute = 0;
|
||||
aItem.startDate.hour++;
|
||||
aItem.endDate = aItem.startDate.clone();
|
||||
aItem.endDate.minute += getPrefSafe("calendar.event.defaultlength", 60);
|
||||
} else if (isToDo(aItem)) {
|
||||
aItem.entryDate = now();
|
||||
aItem.entryDate.second = 0;
|
||||
aItem.entryDate.minute = 0;
|
||||
aItem.entryDate.hour++;
|
||||
}
|
||||
setDefaultStartEndHour(aItem);
|
||||
setDefaultAlarmValues(aItem);
|
||||
|
||||
function addAttendees(aEmailAddresses) {
|
||||
@ -182,10 +169,7 @@ var itemConversion = {
|
||||
// Dates and alarms
|
||||
item.startDate = aTask.entryDate;
|
||||
if (!item.startDate) {
|
||||
item.startDate = now();
|
||||
item.startDate.minute = 0;
|
||||
item.startDate.second = 0;
|
||||
item.startDate.hour++;
|
||||
item.startDate = getDefaultStartDate();
|
||||
}
|
||||
|
||||
item.endDate = aTask.dueDate;
|
||||
|
||||
@ -92,39 +92,30 @@ function createEventWithDialog(calendar, startDate, endDate, summary, event) {
|
||||
} else {
|
||||
event = createEvent();
|
||||
|
||||
if (!startDate) {
|
||||
// Have we shown the calendar view yet? (Lightning)
|
||||
if (currentView().initialized) {
|
||||
startDate = currentView().selectedDay.clone();
|
||||
} else {
|
||||
startDate = jsDateToDateTime(new Date()).getInTimezone(kDefaultTimezone);
|
||||
if (startDate) {
|
||||
event.startDate = startDate.clone();
|
||||
if (startDate.isDate) {
|
||||
// This is a special case where the date is specified, but the
|
||||
// time is not. To take care, we setup up the time to our
|
||||
// default event start time.
|
||||
event.startDate = getDefaultStartDate(event.startDate);
|
||||
}
|
||||
startDate.isDate = true;
|
||||
} else {
|
||||
setDefaultStartEndHour(event);
|
||||
}
|
||||
|
||||
if (startDate.isDate) {
|
||||
if (!startDate.isMutable) {
|
||||
startDate = startDate.clone();
|
||||
}
|
||||
startDate.isDate = false;
|
||||
// The time for the event should default to the next full hour
|
||||
startDate.hour = now().hour + 1;
|
||||
startDate.minute = 0;
|
||||
startDate.second = 0;
|
||||
if (endDate) {
|
||||
event.endDate = endDate.clone();
|
||||
} else {
|
||||
event.endDate = event.startDate.clone();
|
||||
event.endDate.minute += getPrefSafe("calendar.event.defaultlength", 60);
|
||||
}
|
||||
|
||||
if (!endDate) {
|
||||
endDate = startDate.clone();
|
||||
endDate.minute += getPrefSafe("calendar.event.defaultlength", 60);
|
||||
}
|
||||
|
||||
event.startDate = startDate.clone();
|
||||
event.endDate = endDate.clone();
|
||||
|
||||
event.calendar = calendar || getSelectedCalendar();
|
||||
|
||||
if (summary)
|
||||
if (summary) {
|
||||
event.title = summary;
|
||||
}
|
||||
|
||||
setDefaultAlarmValues(event);
|
||||
}
|
||||
|
||||
@ -3462,8 +3462,8 @@
|
||||
<method name="adjustScrollbarSpacersForAlldayEvents">
|
||||
<parameter name="aEvent"/>
|
||||
<body><![CDATA[
|
||||
var startDate = calGetStartDate(aEvent);
|
||||
var endDate = calGetEndDate(aEvent);
|
||||
var startDate = aEvent[calGetStartDateProp(aEvent)];
|
||||
var endDate = aEvent[calGetEndDateProp(aEvent)];
|
||||
if (startDate && startDate.isDate ||
|
||||
endDate && endDate.isDate) {
|
||||
// If this is an all day event, then the header with allday
|
||||
|
||||
@ -1288,6 +1288,48 @@ function ensureDateTime(aDate) {
|
||||
return newDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default event start date. This is the next full hour, or 23:00 if it
|
||||
* is past 23:00.
|
||||
*
|
||||
* @param aReferenceDate If passed, the time of this date will be modified,
|
||||
* keeping the date and timezone intact.
|
||||
*/
|
||||
function getDefaultStartDate(aReferenceDate) {
|
||||
var startDate = now();
|
||||
if (aReferenceDate) {
|
||||
var savedHour = startDate.hour;
|
||||
startDate = aReferenceDate;
|
||||
if (!startDate.isMutable) {
|
||||
startDate = startDate.clone();
|
||||
}
|
||||
startDate.isDate = false;
|
||||
startDate.hour = savedHour;
|
||||
}
|
||||
|
||||
startDate.second = 0;
|
||||
startDate.minute = 0;
|
||||
if (startDate.hour < 23) {
|
||||
startDate.hour++;
|
||||
}
|
||||
return startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the default start and end hours of the given item. This can be a task
|
||||
* or an event.
|
||||
*
|
||||
* @param aItem The item to set up the start and end date for.
|
||||
*/
|
||||
function setDefaultStartEndHour(aItem) {
|
||||
aItem[calGetStartDateProp(aItem)] = getDefaultStartDate();
|
||||
|
||||
if (isEvent(aItem)) {
|
||||
aItem.endDate = aItem.startDate.clone();
|
||||
aItem.endDate.minute += getPrefSafe("calendar.event.defaultlength", 60);
|
||||
}
|
||||
}
|
||||
|
||||
/****
|
||||
**** debug code
|
||||
****/
|
||||
@ -1552,19 +1594,29 @@ function getContrastingTextColor(bgColor)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the start date of an item, ie either an event's start date or a task's entry date.
|
||||
* Returns the property name used for the start date of an item, ie either an
|
||||
* event's start date or a task's entry date.
|
||||
*/
|
||||
function calGetStartDate(aItem)
|
||||
{
|
||||
return (isEvent(aItem) ? aItem.startDate : aItem.entryDate);
|
||||
function calGetStartDateProp(aItem) {
|
||||
if (isEvent(aItem)) {
|
||||
return "startDate";
|
||||
} else if (isToDo(aItem)) {
|
||||
return "entryDate";
|
||||
}
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the end date of an item, ie either an event's end date or a task's due date.
|
||||
* Returns the property name used for the end date of an item, ie either an
|
||||
* event's end date or a task's due date.
|
||||
*/
|
||||
function calGetEndDate(aItem)
|
||||
{
|
||||
return (isEvent(aItem) ? aItem.endDate : aItem.dueDate);
|
||||
function calGetEndDateProp(aItem) {
|
||||
if (isEvent(aItem)) {
|
||||
return "endDate";
|
||||
} else if (isToDo(aItem)) {
|
||||
return "dueDate";
|
||||
}
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
* Contributor(s):
|
||||
* Michiel van Leeuwen <mvl@exedo.nl>
|
||||
* Daniel Boelzle <daniel.boelzle@sun.com>
|
||||
* Philipp Kewisch <mozilla@kewis.ch>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -103,11 +104,11 @@ function html_exportToStream(aStream, aCount, aItems, aTitle) {
|
||||
|
||||
// Sort aItems
|
||||
function sortFunc(a, b) {
|
||||
var start_a = calGetStartDate(a);
|
||||
var start_a = a[calGetStartDateProp(a)];
|
||||
if (!start_a) {
|
||||
return -1;
|
||||
}
|
||||
var start_b = calGetStartDate(b);
|
||||
var start_b = b[calGetStartDateProp(b)];
|
||||
if (!start_b) {
|
||||
return 1;
|
||||
}
|
||||
@ -136,8 +137,8 @@ function html_exportToStream(aStream, aCount, aItems, aTitle) {
|
||||
</div>
|
||||
);
|
||||
|
||||
var startDate = calGetStartDate(item);
|
||||
var endDate = calGetEndDate(item);
|
||||
var startDate = item[calGetStartDateProp(item)];
|
||||
var endDate = item[calGetEndDateProp(item)];
|
||||
if (startDate) {
|
||||
startDate = startDate.getInTimezone(defaultTimezone);
|
||||
}
|
||||
|
||||
@ -1981,12 +1981,8 @@ function updateDateTime() {
|
||||
endTime.timezone = floating();
|
||||
setElementValue("todo-duedate", endTime.jsDate);
|
||||
} else {
|
||||
// The time for the todo should default to the next full hour
|
||||
startTime = now();
|
||||
startTime = getDefaultStartDate();
|
||||
startTime.timezone = floating();
|
||||
startTime.minute = 0;
|
||||
startTime.second = 0;
|
||||
startTime.hour++;
|
||||
endTime = startTime.clone();
|
||||
|
||||
setElementValue("todo-entrydate", startTime.jsDate);
|
||||
@ -2040,12 +2036,8 @@ function updateDateTime() {
|
||||
endTime.timezone = floating();
|
||||
setElementValue("todo-duedate", endTime.jsDate);
|
||||
} else {
|
||||
// The time for the todo should default to the next full hour
|
||||
startTime = now();
|
||||
startTime = getDefaultStartDate();
|
||||
startTime.timezone = floating();
|
||||
startTime.minute = 0;
|
||||
startTime.second = 0;
|
||||
startTime.hour++;
|
||||
endTime = startTime.clone();
|
||||
|
||||
setElementValue("todo-entrydate", startTime.jsDate);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user