[gnome-shell] dateMenu: Don't limit weather forecasts to the same day
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] dateMenu: Don't limit weather forecasts to the same day
- Date: Sat, 23 Nov 2019 00:23:20 +0000 (UTC)
commit b757f5c655b2fdb9459cdcda8894859719e3fd05
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Nov 20 23:23:50 2019 +0100
dateMenu: Don't limit weather forecasts to the same day
As we get closer to midnight, we show fewer forecasts than we could
fit, or none at all. It makes more sense to continue the forecasts
into the wee hours in that case, so only exclude past forecasts,
but not ones from following days.
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1927
js/ui/dateMenu.js | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 1e630897bc..ec75653d87 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -312,17 +312,18 @@ class WeatherSection extends St.Button {
let info = this._weatherClient.info;
let forecasts = info.get_forecast_list();
+ let now = GLib.DateTime.new_now_local();
let current = info;
let infos = [info];
for (let i = 0; i < forecasts.length; i++) {
let [ok_, timestamp] = forecasts[i].get_value_update();
- let datetime = new Date(timestamp * 1000);
- if (!_isToday(datetime))
- continue; // Ignore forecasts from other days
+ const datetime = GLib.DateTime.new_from_unix_local(timestamp);
+ if (now.difference(datetime) > 0)
+ continue; // Ignore earlier forecasts
[ok_, timestamp] = current.get_value_update();
- let currenttime = new Date(timestamp * 1000);
- if (currenttime.getHours() == datetime.getHours())
+ const currenttime = GLib.DateTime.new_from_unix_local(timestamp);
+ if (datetime.difference(currenttime) < GLib.TIME_SPAN_HOUR)
continue; // Enforce a minimum interval of 1h
current = forecasts[i];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]