[gnome-shell] dateMenu: Port to GWeather 4.0



commit ab52ce4591839e2c6883c6034dfdfe73b2e630be
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Jan 5 03:18:08 2022 +0100

    dateMenu: Port to GWeather 4.0
    
    Besides dropping its GTK dependency (which doesn't affect us),
    GWeather 4.0 replaces its own timezone type with GTimeZone.
    
    It's easy enough to adjust to that, so port over to the new
    version.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2083>

 .gitlab-ci.yml       |  2 +-
 js/ui/dateMenu.js    | 18 +++++++++---------
 js/ui/environment.js |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b40419662a..32eade1555 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -31,7 +31,7 @@ variables:
   LINT_LOG: "eslint-report.xml"
   LINT_MR_LOG: "eslint-mr-report.xml"
 
-image: registry.gitlab.gnome.org/gnome/mutter/fedora/34:x86_64-2021-09-15.0
+image: registry.gitlab.gnome.org/gnome/mutter/fedora/35:x86_64-2022-01-05.0
 
 workflow:
   rules:
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 6edd790a05..89289179ba 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -339,9 +339,13 @@ class WorldClocksSection extends St.Button {
                 this._locations.push({ location: l });
         }
 
+        const unixtime = GLib.DateTime.new_now_local().to_unix();
         this._locations.sort((a, b) => {
-            return a.location.get_timezone().get_offset() -
-                   b.location.get_timezone().get_offset();
+            const tzA = a.location.get_timezone();
+            const tzB = b.location.get_timezone();
+            const intA = tzA.find_interval(GLib.TimeType.STANDARD, unixtime);
+            const intB = tzA.find_interval(GLib.TimeType.STANDARD, unixtime);
+            return tzA.get_offset(intA) - tzB.get_offset(intB);
         });
 
         let layout = this._grid.layout_manager;
@@ -412,8 +416,9 @@ class WorldClocksSection extends St.Button {
     }
 
     _getTimezoneOffsetAtLocation(location) {
+        const tz = location.get_timezone();
         const localOffset = GLib.DateTime.new_now_local().get_utc_offset();
-        const utcOffset = this._getTimeAtLocation(location).get_utc_offset();
+        const utcOffset = GLib.DateTime.new_now(tz).get_utc_offset();
         const offsetCurrentTz = utcOffset - localOffset;
         const offsetHours = Math.abs(offsetCurrentTz) / GLib.TIME_SPAN_HOUR;
         const offsetMinutes =
@@ -427,15 +432,10 @@ class WorldClocksSection extends St.Button {
         return text;
     }
 
-    _getTimeAtLocation(location) {
-        let tz = GLib.TimeZone.new(location.get_timezone().get_tzid());
-        return GLib.DateTime.new_now(tz);
-    }
-
     _updateTimeLabels() {
         for (let i = 0; i < this._locations.length; i++) {
             let l = this._locations[i];
-            let now = this._getTimeAtLocation(l.location);
+            const now = GLib.DateTime.new_now(l.location.get_timezone());
             l.timeLabel.text = Util.formatTime(now, { timeOnly: true });
         }
     }
diff --git a/js/ui/environment.js b/js/ui/environment.js
index ad2b8e4f28..67571152a6 100644
--- a/js/ui/environment.js
+++ b/js/ui/environment.js
@@ -9,7 +9,7 @@ imports.gi.versions.GdkPixbuf = '2.0';
 imports.gi.versions.GnomeBluetooth = '1.0';
 imports.gi.versions.GnomeDesktop = '3.0';
 imports.gi.versions.Gtk = '3.0';
-imports.gi.versions.GWeather = '3.0';
+imports.gi.versions.GWeather = '4.0';
 imports.gi.versions.Soup = '3.0';
 imports.gi.versions.TelepathyGLib = '0.12';
 imports.gi.versions.TelepathyLogger = '0.2';


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