[gnome-shell] [Calendar] Fix wrong start date in corner case



commit e7fb2c50a3c81aedab375baa1154684796941907
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Aug 1 12:47:16 2010 +0200

    [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 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index a26f123..078c69d 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();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]