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>
This commit is contained in:
Florian Müllner 2022-01-05 03:18:08 +01:00
parent f07a40d5ee
commit ab52ce4591
3 changed files with 11 additions and 11 deletions

View File

@ -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:

View File

@ -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 });
}
}

View File

@ -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';