From e7fb2c50a3c81aedab375baa1154684796941907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sun, 1 Aug 2010 12:47:16 +0200 Subject: [PATCH] [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 --- js/ui/calendar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/ui/calendar.js b/js/ui/calendar.js index a26f12305..078c69d82 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -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();