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
This commit is contained in:
parent
784c0b7e4b
commit
b757f5c655
@ -312,17 +312,18 @@ class WeatherSection extends St.Button {
|
|||||||
let info = this._weatherClient.info;
|
let info = this._weatherClient.info;
|
||||||
let forecasts = info.get_forecast_list();
|
let forecasts = info.get_forecast_list();
|
||||||
|
|
||||||
|
let now = GLib.DateTime.new_now_local();
|
||||||
let current = info;
|
let current = info;
|
||||||
let infos = [info];
|
let infos = [info];
|
||||||
for (let i = 0; i < forecasts.length; i++) {
|
for (let i = 0; i < forecasts.length; i++) {
|
||||||
let [ok_, timestamp] = forecasts[i].get_value_update();
|
let [ok_, timestamp] = forecasts[i].get_value_update();
|
||||||
let datetime = new Date(timestamp * 1000);
|
const datetime = GLib.DateTime.new_from_unix_local(timestamp);
|
||||||
if (!_isToday(datetime))
|
if (now.difference(datetime) > 0)
|
||||||
continue; // Ignore forecasts from other days
|
continue; // Ignore earlier forecasts
|
||||||
|
|
||||||
[ok_, timestamp] = current.get_value_update();
|
[ok_, timestamp] = current.get_value_update();
|
||||||
let currenttime = new Date(timestamp * 1000);
|
const currenttime = GLib.DateTime.new_from_unix_local(timestamp);
|
||||||
if (currenttime.getHours() == datetime.getHours())
|
if (datetime.difference(currenttime) < GLib.TIME_SPAN_HOUR)
|
||||||
continue; // Enforce a minimum interval of 1h
|
continue; // Enforce a minimum interval of 1h
|
||||||
|
|
||||||
current = forecasts[i];
|
current = forecasts[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user