Bug 511476 - calendar-event-dialog-freebusy.xml: Remove obsolete range check. r=philipp

This commit is contained in:
Martin Schroeder 2009-08-25 16:18:08 +02:00
Родитель f2bce9caed
Коммит 898206a435
1 изменённых файлов: 73 добавлений и 78 удалений

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

@ -22,6 +22,7 @@
- Michael Buettner <michael.buettner@sun.com> - Michael Buettner <michael.buettner@sun.com>
- Philipp Kewisch <mozilla@kewis.ch> - Philipp Kewisch <mozilla@kewis.ch>
- Simon Vaillancourt <simon.at.orcl@gmail.com> - Simon Vaillancourt <simon.at.orcl@gmail.com>
- Martin Schroeder <mschroeder@mozilla.x-home.org>
- -
- Alternatively, the contents of this file may be used under the terms of - 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 - either the GNU General Public License Version 2 or later (the "GPL"), or
@ -810,98 +811,92 @@
for each (let entry in aEntries) { for each (let entry in aEntries) {
let rangeStart = entry.interval.start.getInTimezone(kDefaultTimezone); let rangeStart = entry.interval.start.getInTimezone(kDefaultTimezone);
let rangeEnd = entry.interval.end.getInTimezone(kDefaultTimezone); let rangeEnd = entry.interval.end.getInTimezone(kDefaultTimezone);
if (rangeStart.compare(start) < 0) {
rangeStart = start.clone();
}
if (rangeEnd.compare(end) > 0) {
rangeEnd = end.clone();
}
if (rangeStart.compare(start) >= 0 && if (rangeStart.compare(start) < 0) {
rangeEnd.compare(end) <= 0) { rangeStart = start.clone();
let rangeDuration = rangeEnd.subtractDate(rangeStart); }
let rangeStartHour = rangeStart.hour; if (rangeEnd.compare(end) > 0) {
let rangeEndHour = rangeStartHour + (rangeDuration.inSeconds / 3600); rangeEnd = end.clone();
}
if ((rangeStartHour < this.mEndHour) && let rangeDuration = rangeEnd.subtractDate(rangeStart);
(rangeEndHour >= this.mStartHour)) { let rangeStartHour = rangeStart.hour;
let dayingrid = start.clone(); let rangeEndHour = rangeStartHour + (rangeDuration.inSeconds / 3600);
dayingrid.year = rangeStart.year;
dayingrid.month = rangeStart.month;
dayingrid.day = rangeStart.day;
dayingrid.getInTimezone(kDefaultTimezone);
// Ok, this is an entry we're interested in. Find out if ((rangeStartHour < this.mEndHour) &&
// which hours are actually occupied. (rangeEndHour >= this.mStartHour)) {
let offset = rangeStart.subtractDate(dayingrid); let dayingrid = start.clone();
dayingrid.year = rangeStart.year;
dayingrid.month = rangeStart.month;
dayingrid.day = rangeStart.day;
dayingrid.getInTimezone(kDefaultTimezone);
// Calculate how many days we're offset from the // Ok, this is an entry we're interested in. Find out
// start of the grid. Eliminate hours in case // which hours are actually occupied.
// we encounter the daylight-saving hop. let offset = rangeStart.subtractDate(dayingrid);
let dayoffset = dayingrid.subtractDate(start);
dayoffset.hours = 0;
// Add both offsets to find the total offset. // Calculate how many days we're offset from the
// dayoffset -> offset in days from start of grid // start of the grid. Eliminate hours in case
// offset -> offset in hours from start of current day // we encounter the daylight-saving hop.
offset.addDuration(dayoffset); let dayoffset = dayingrid.subtractDate(start);
dayoffset.hours = 0;
let duration = rangeEnd.subtractDate(rangeStart); // Add both offsets to find the total offset.
let start_in_minutes = Math.floor(offset.inSeconds / 60); // dayoffset -> offset in days from start of grid
let end_in_minutes = Math.ceil((duration.inSeconds / 60) + // offset -> offset in hours from start of current day
(offset.inSeconds / 60)); offset.addDuration(dayoffset);
function minute2offset(value, let duration = rangeEnd.subtractDate(rangeStart);
fNumHours, let start_in_minutes = Math.floor(offset.inSeconds / 60);
numHours, let end_in_minutes = Math.ceil((duration.inSeconds / 60) +
start_hour, (offset.inSeconds / 60));
zoomfactor) {
// 'value' is some integer in the interval [0, range * 24 * 60].
// we need to map this offset into our array which
// holds elements for 'range' days with [start, end] hours each.
let minutes_per_day = 24 * 60;
let day = (value - (value % minutes_per_day)) /
minutes_per_day;
let minute = Math.floor(
value % minutes_per_day) -
(start_hour * 60);
minute = Math.max(0, minute); function minute2offset(value,
fNumHours,
numHours,
start_hour,
zoomfactor) {
// 'value' is some integer in the interval [0, range * 24 * 60].
// we need to map this offset into our array which
// holds elements for 'range' days with [start, end] hours each.
let minutes_per_day = 24 * 60;
let day = (value - (value % minutes_per_day)) / minutes_per_day;
let minute = Math.floor(value % minutes_per_day) - (start_hour * 60);
if (minute >= (numHours * 60)) { minute = Math.max(0, minute);
minute = (numHours * 60) - 1;
}
// How to get from minutes to offset?
// 60 = 100%, 30 = 50%, 15 = 25%, etc.
let minutes_per_block = 60 * zoomfactor / 100;
let block = Math.floor(minute / minutes_per_block); if (minute >= (numHours * 60)) {
minute = (numHours * 60) - 1;
return Math.ceil(fNumHours) * day + block;
} }
// How to get from minutes to offset?
// 60 = 100%, 30 = 50%, 15 = 25%, etc.
let minutes_per_block = 60 * zoomfactor / 100;
// Number of hours (fractional representation) let block = Math.floor(minute / minutes_per_block);
let numHours = this.mEndHour - this.mStartHour;
let fNumHours = numHours * 100 / this.mZoomFactor;
let start_offset = return Math.ceil(fNumHours) * day + block;
minute2offset(start_in_minutes, }
fNumHours,
numHours,
this.mStartHour,
this.mZoomFactor);
let end_offset =
minute2offset(end_in_minutes - 1,
fNumHours,
numHours,
this.mStartHour,
this.mZoomFactor);
// Set all affected state slots // Number of hours (fractional representation)
for (let i = start_offset; i <= end_offset; i++) { let numHours = this.mEndHour - this.mStartHour;
this.mState[i] = entry.freeBusyType; let fNumHours = numHours * 100 / this.mZoomFactor;
}
let start_offset =
minute2offset(start_in_minutes,
fNumHours,
numHours,
this.mStartHour,
this.mZoomFactor);
let end_offset =
minute2offset(end_in_minutes - 1,
fNumHours,
numHours,
this.mStartHour,
this.mZoomFactor);
// Set all affected state slots
for (let i = start_offset; i <= end_offset; i++) {
this.mState[i] = entry.freeBusyType;
} }
} }
} }