Bug 328763 Alarm for all day event always set to 00:00:00 UTC. r=dmose

This commit is contained in:
jminta%gmail.com 2006-03-01 04:42:01 +00:00
Родитель 2bd52a2d41
Коммит ad451f0f7e
4 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -50,11 +50,20 @@ interface calIAlarmServiceObserver : nsISupports
[scriptable,uuid(03669cf3-bf4f-4692-97a1-cca891964a1d)]
interface calIAlarmService : nsISupports
{
/**
* This is the timezone that all-day events will be converted to in order to
* determine when their alarms should fire.
*/
attribute AUTF8String timezone;
/**
* Cause the alarm service to start up, create a list of upcoming
* alarms in all registered calendars, add observers to watch for
* calendar registration and unregistration, and setup a timer to
* maintain that list and fire alarms.
*
* @note Will throw NS_ERROR_NOT_INITIALIZED if you have not previously set
* the timezone attribute.
*/
void startup();

Просмотреть файл

@ -168,6 +168,15 @@ calAlarmService.prototype = {
},
/* calIAlarmService APIs */
mTimezone: null,
get timezone() {
return this.mTimezone;
},
set timezone(aTimezone) {
this.mTimezone = aTimezone;
},
snoozeEvent: function(event, duration) {
/* modify the event for a new alarm time */
var newEvent = event.clone();
@ -222,6 +231,10 @@ calAlarmService.prototype = {
if (this.mStarted)
return;
if (!this.mTimezone) {
throw Components.results.NS_ERROR_NOT_INITIALIZED;
}
dump("Starting calendar alarm service\n");
var observerSvc = Components.classes["@mozilla.org/observer-service;1"]
@ -317,6 +330,15 @@ calAlarmService.prototype = {
}
alarmTime = alarmTime.clone();
// Handle all day events. This is kinda weird, because they don't have
// a well defined startTime. We just consider the start/end to be
// midnight in the user's timezone.
if (alarmTime.isDate) {
alarmTime = alarmTime.getInTimezone(this.mTimezone);
alarmTime.isDate = false;
}
alarmTime.addDuration(aItem.alarmOffset);
alarmTime = alarmTime.getInTimezone("UTC");
dump("considering alarm for item:"+aItem.title+'\n offset:'+aItem.alarmOffset+', which makes alarm time:'+alarmTime+'\n');

Просмотреть файл

@ -105,6 +105,7 @@ function ltnOnLoad(event)
// fire up the alarm service
var alarmSvc = Components.classes["@mozilla.org/calendar/alarm-service;1"]
.getService(Components.interfaces.calIAlarmService);
alarmSvc.timezone = calendarDefaultTimezone();
alarmSvc.startup();
// Add an unload function to the window so we don't leak the pref observer

Просмотреть файл

@ -125,6 +125,7 @@ function calendarInit()
// fire up the alarm service
var alarmSvc = Components.classes["@mozilla.org/calendar/alarm-service;1"]
.getService(Components.interfaces.calIAlarmService);
alarmSvc.timezone = calendarDefaultTimezone();
alarmSvc.startup();
if (("arguments" in window) && (window.arguments.length) &&