diff options
author | Erich Eckner <git@eckner.net> | 2020-08-12 14:29:02 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-08-12 14:29:02 +0200 |
commit | 59bfcaec39a4779007eb27944c895a2b2832cd2f (patch) | |
tree | 9a2fcf5eef87fd1387ce0983a9e5810b70dd636a /input_gadgets.c | |
parent | 67f72eb31718f4a584ad164dd9a54fa758ca0fc9 (diff) | |
download | anzeige-59bfcaec39a4779007eb27944c895a2b2832cd2f.tar.xz |
input_gadgets.c: skip redundant warnings
Diffstat (limited to 'input_gadgets.c')
-rw-r--r-- | input_gadgets.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/input_gadgets.c b/input_gadgets.c index 97351c4..c55ced4 100644 --- a/input_gadgets.c +++ b/input_gadgets.c @@ -1034,7 +1034,17 @@ char *gadgets_retrieve_weather_warnings(char *output, int max_len) if ((!warnings_len) && (max_len > 0)) ende += snprintf(ende, max_len, "%s", "keine Warnungen"); for (int i=0; i<warnings_len; i++) { - if (output + max_len - ende > 0) { + int is_relevant = 1; + for (int j=0; j<i; j++) { + if (strcmp(warnings[i].event, warnings[j].event) != 0) + continue; + if ((warnings[i].onset != warnings[j].onset) || ((warnings[i].onset <= time(NULL)) && (warnings[j].onset <= time(NULL)))) + continue; + if ((warnings[i].expires != warnings[j].expires) || ((warnings[i].expires < time(NULL) + warnings_future_timespan) && (warnings[j].expires < time(NULL) + warnings_future_timespan))) + continue; + is_relevant = 0; + } + if (is_relevant && (output + max_len - ende > 0)) { ende += snprintf(ende, output + max_len - ende, "%s", warnings[i].event); if (output + max_len - ende > 0) { if (warnings[i].onset > time(NULL)) { |