rem: var timer = Components.classes["@mozilla.org/timer;1"] .createInstance(Components.interfaces.nsITimer); timer.initWithCallback(udCallback, msUntilTomorrow, timer.TYPE_ONE_SHOT); 
add: if (!gMidnightTimer) {  var wakeObserver = { observe: function(aSubject, aTopic, aData) { if (aTopic == "wake_notification") { aRefreshCallback(); } } };   var observerService = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); observerService.addObserver(wakeObserver, "wake_notification", false);   window.addEventListener("unload", function() { observerService.removeObserver(wakeObserver, "wake_notification"); }, false);  gMidnightTimer = Components.classes["@mozilla.org/timer;1"] .createInstance(Components.interfaces.nsITimer); } else { gMidnightTimer.cancel(); } gMidnightTimer.initWithCallback(udCallback, msUntilTomorrow, gMidnightTimer.TYPE_ONE_SHOT); 
context: function scheduleMidnightUpdate(aRefreshCallback) {    var jsNow = new Date();    var tomorrow = new Date(jsNow.getFullYear(), jsNow.getMonth(), jsNow.getDate() + 1);    var msUntilTomorrow = tomorrow.getTime() - jsNow.getTime();    // Is an nsITimer/callback extreme overkill here? Yes, but it's necessary to    // workaround bug 291386.  If we don't, we stand a decent chance of getting    // stuck in an infinite loop.    var udCallback = {        notify: function(timer) {            aRefreshCallback();        }    };    var timer = Components.classes["@mozilla.org/timer;1"]                          .createInstance(Components.interfaces.nsITimer);    timer.initWithCallback(udCallback, msUntilTomorrow, timer.TYPE_ONE_SHOT);}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/9421/7c7a2f72dc51cc404376de2148cdffb3fbb2f789/calendar-views.js/clean/calendar/base/content/calendar-views.js