[Calendar] Fix wrong start date in corner case

The start date is shifted by a week if the day number of the month's
first day is smaller than the week start's day number. Probably the
only real world examples are months starting on a Sunday with locales
using Monday as start of week.

https://bugzilla.gnome.org/show_bug.cgi?id=625756
This commit is contained in:
Florian Müllner 2010-08-01 12:47:16 +02:00
parent 09374b08a3
commit e7fb2c50a3

View File

@ -226,7 +226,8 @@ Calendar.prototype = {
iter.setDate(1);
iter.setSeconds(0);
iter.setHours(12);
iter.setTime(iter.getTime() - (iter.getDay() - this._weekStart) * MSECS_IN_DAY);
let daysToWeekStart = (7 + iter.getDay() - this._weekStart) % 7;
iter.setTime(iter.getTime() - daysToWeekStart * MSECS_IN_DAY);
let now = new Date();