[gnome-shell/f21] Add 0001-calendar-Stop-computing-week-number-ourselves patch

Daniel Williams dcbw at fedoraproject.org
Fri Mar 13 21:34:18 UTC 2015


commit e9bdb86c7f6b2bced9d8ea46fa9c356e934cccd0
Author: Dan Williams <dcbw at redhat.com>
Date:   Fri Mar 13 16:34:05 2015 -0500

    Add 0001-calendar-Stop-computing-week-number-ourselves patch

 ...ndar-Stop-computing-week-number-ourselves.patch | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)
---
diff --git a/0001-calendar-Stop-computing-week-number-ourselves.patch b/0001-calendar-Stop-computing-week-number-ourselves.patch
new file mode 100644
index 0000000..ce0f15c
--- /dev/null
+++ b/0001-calendar-Stop-computing-week-number-ourselves.patch
@@ -0,0 +1,54 @@
+From 1e8e5d4671f017926098fdf6bd79310372607713 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner at gnome.org>
+Date: Thu, 13 Nov 2014 15:14:56 +0000
+Subject: [PATCH] calendar: Stop computing week number ourselves
+
+Correctly computing the ISO week number is tricky and we already
+have code in the platform to do it, so just refer its computation
+to GDateTime rather than doing it ourselves.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=736722
+---
+ js/ui/calendar.js | 19 +------------------
+ 1 file changed, 1 insertion(+), 18 deletions(-)
+
+diff --git a/js/ui/calendar.js b/js/ui/calendar.js
+index 127eb2d..4132c00 100644
+--- a/js/ui/calendar.js
++++ b/js/ui/calendar.js
+@@ -88,23 +88,6 @@ function _formatEventTime(event, clockFormat, periodBegin, periodEnd) {
+     return ret;
+ }
+ 
+-function _getCalendarWeekForDate(date) {
+-    // Based on the algorithms found here:
+-    // http://en.wikipedia.org/wiki/Talk:ISO_week_date
+-    let midnightDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
+-    // Need to get Monday to be 1 ... Sunday to be 7
+-    let dayOfWeek = 1 + ((midnightDate.getDay() + 6) % 7);
+-    let nearestThursday = new Date(midnightDate.getFullYear(), midnightDate.getMonth(),
+-                                   midnightDate.getDate() + (4 - dayOfWeek));
+-
+-    let jan1st = new Date(nearestThursday.getFullYear(), 0, 1);
+-    let diffDate = nearestThursday - jan1st;
+-    let dayNumber = Math.floor(Math.abs(diffDate) / MSECS_IN_DAY);
+-    let weekNumber = Math.floor(dayNumber / 7) + 1;
+-
+-    return weekNumber;
+-}
+-
+ function _getCalendarDayAbbreviation(dayNumber) {
+     let abbreviations = [
+         /* Translators: Calendar grid abbreviation for Sunday.
+@@ -669,7 +652,7 @@ const Calendar = new Lang.Class({
+             this._buttons.push(button);
+ 
+             if (this._useWeekdate && iter.getDay() == 4) {
+-                let label = new St.Label({ text: _getCalendarWeekForDate(iter).toString(),
++                let label = new St.Label({ text: iter.toLocaleFormat('%V'),
+                                            style_class: 'calendar-day-base calendar-week-number'});
+                 layout.attach(label, rtl ? 7 : 0, row, 1, 1);
+             }
+-- 
+2.1.0
+


More information about the scm-commits mailing list