View | Details | Raw Unified | Return to bug 236735
Collapse All | Expand All

(-)Makefile (-5 / +2 lines)
Lines 2-9 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	xfce4-weather-plugin
4
PORTNAME=	xfce4-weather-plugin
5
PORTVERSION=	0.9.0
5
PORTVERSION=	0.9.1
6
PORTREVISION=	1
7
CATEGORIES=	misc xfce geography
6
CATEGORIES=	misc xfce geography
8
MASTER_SITES=	XFCE/src/panel-plugins/${PORTNAME}/${PORTVERSION:R}
7
MASTER_SITES=	XFCE/src/panel-plugins/${PORTNAME}/${PORTVERSION:R}
9
DIST_SUBDIR=	xfce4
8
DIST_SUBDIR=	xfce4
Lines 14-22 Link Here
14
LICENSE=	GPLv2
13
LICENSE=	GPLv2
15
LICENSE_FILE=	${WRKSRC}/COPYING
14
LICENSE_FILE=	${WRKSRC}/COPYING
16
15
17
LIB_DEPENDS=	libsoup-2.4.so:devel/libsoup \
16
LIB_DEPENDS=	libsoup-2.4.so:devel/libsoup
18
		libfontconfig.so:x11-fonts/fontconfig \
19
		libfreetype.so:print/freetype2
20
17
21
USES=		gettext-tools gmake gnome libtool pkgconfig tar:bzip2 xfce:gtk3
18
USES=		gettext-tools gmake gnome libtool pkgconfig tar:bzip2 xfce:gtk3
22
USE_GNOME=	cairo glib20 gtk30 intltool libxml2
19
USE_GNOME=	cairo glib20 gtk30 intltool libxml2
(-)distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1537628267
1
TIMESTAMP = 1553349293
2
SHA256 (xfce4/xfce4-weather-plugin-0.9.0.tar.bz2) = 34368cf2332774ad2a05226b2914ecb60e7550e9b2164be53ebe8f370198bb3d
2
SHA256 (xfce4/xfce4-weather-plugin-0.9.1.tar.bz2) = 7cdc18b8df759dee4ceaaf6ce303eff7fda48e247dbc26b78142929213506cfd
3
SIZE (xfce4/xfce4-weather-plugin-0.9.0.tar.bz2) = 2953904
3
SIZE (xfce4/xfce4-weather-plugin-0.9.1.tar.bz2) = 3018842
(-)files/patch-new_sunrise_API (-673 lines)
Lines 1-673 Link Here
1
From cc20f088a694613bc2d7551070208dfb9221f9d7 Mon Sep 17 00:00:00 2001
2
From: Olivier Duchateau <duchateau.olivier@gmail.com>
3
Date: Sat, 2 Mar 2019 18:57:09 +0100
4
Subject: [PATCH] Use the latest sunrise API (2.0)
5
6
---
7
 panel-plugin/weather-data.c    |  12 +--
8
 panel-plugin/weather-data.h    |   2 +-
9
 panel-plugin/weather-parsers.c | 185 +++++++++++++++++----------------
10
 panel-plugin/weather-summary.c |  20 ++--
11
 panel-plugin/weather.c         | 103 +++++++++++-------
12
 panel-plugin/weather.h         |   3 +
13
 6 files changed, 184 insertions(+), 141 deletions(-)
14
15
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
16
index cbc7da5..008a60c 100644
17
--- panel-plugin/weather-data.c
18
+++ panel-plugin/weather-data.c
19
@@ -105,25 +105,25 @@ double_to_string(const gdouble val,
20
 
21
 
22
 gchar *
23
-format_date(const time_t date_t,
24
+format_date(time_t date_t,
25
             gchar *format,
26
             gboolean local)
27
 {
28
     struct tm *tm;
29
-    time_t t = date_t;
30
     gchar buf[40];
31
     size_t size;
32
 
33
+    if (format == NULL)
34
+        format = "%Y-%m-%d %H:%M:%S";
35
+
36
     if (G_LIKELY(local))
37
-        tm = localtime(&t);
38
+        tm = localtime(&date_t);
39
     else
40
-        tm = gmtime(&t);
41
+        tm = gmtime(&date_t);
42
 
43
     /* A year <= 1970 means date has not been set */
44
     if (G_UNLIKELY(tm == NULL) || tm->tm_year <= 70)
45
         return g_strdup("-");
46
-    if (format == NULL)
47
-        format = "%Y-%m-%d %H:%M:%S";
48
     size = strftime(buf, 40, format, tm);
49
     return (size ? g_strdup(buf) : g_strdup("-"));
50
 }
51
diff --git a/panel-plugin/weather-data.h b/panel-plugin/weather-data.h
52
index 73f5195..63be6aa 100644
53
--- panel-plugin/weather-data.h
54
+++ panel-plugin/weather-data.h
55
@@ -103,7 +103,7 @@ gdouble string_to_double(const gchar *str,
56
 gchar *double_to_string(gdouble val,
57
                         const gchar *format);
58
 
59
-gchar *format_date(const time_t t,
60
+gchar *format_date(time_t t,
61
                    gchar *format,
62
                    gboolean local);
63
 
64
diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
65
index d23df2c..ef6f269 100644
66
--- panel-plugin/weather-parsers.c
67
+++ panel-plugin/weather-parsers.c
68
@@ -35,6 +35,9 @@
69
 #include <stdlib.h>
70
 #include <string.h>
71
 
72
+#include <libxml/parser.h>
73
+#include <libxml/tree.h>
74
+
75
 
76
 #define DATA(node)                                                  \
77
     ((gchar *) xmlNodeListGetString(node->doc, node->children, 1))
78
@@ -71,6 +74,28 @@ my_timegm(struct tm *tm)
79
 }
80
 
81
 
82
+/*
83
+ * Remove offset of timezone, in order to keep previous
84
+ * date format (before the new API, 2.x).
85
+ */
86
+static gchar *
87
+remove_timezone_offset(gchar *date)
88
+{
89
+    GRegex *re = NULL;
90
+    const gchar *pattern = "[+-][0-9]{2}:[0-9]{2}";
91
+    gchar *res;
92
+
93
+    re = g_regex_new(pattern, 0, 0, NULL);
94
+    if (re != NULL && g_regex_match(re, date, 0, NULL)) {
95
+        res = g_regex_replace(re, date, -1, 0, "Z", 0, NULL);
96
+    } else {
97
+        res = date;
98
+    }
99
+    g_regex_unref(re);
100
+    return res;
101
+}
102
+
103
+
104
 xml_time *
105
 get_timeslice(xml_weather *wd,
106
               const time_t start_t,
107
@@ -128,9 +153,10 @@ parse_timestring(const gchar *ts,
108
     time_t t;
109
     struct tm tm;
110
 
111
-    memset(&t, 0, sizeof(time_t));
112
-    if (G_UNLIKELY(ts == NULL))
113
+    if (G_UNLIKELY(ts == NULL)) {
114
+        memset(&t, 0, sizeof(time_t));
115
         return t;
116
+    }
117
 
118
     /* standard format */
119
     if (format == NULL)
120
@@ -141,15 +167,22 @@ parse_timestring(const gchar *ts,
121
     memset(&tm, 0, sizeof(struct tm));
122
     tm.tm_isdst = -1;
123
 
124
-    if (G_UNLIKELY(strptime(ts, format, &tm) == NULL))
125
-        return t;
126
-
127
-    if (local)
128
-        t = mktime(&tm);
129
-    else
130
-        t = my_timegm(&tm);
131
+    if (strptime(ts, format, &tm) != NULL) {
132
+        if (local)
133
+            t = mktime(&tm);
134
+        else
135
+            t = my_timegm(&tm);
136
 
137
-    return t;
138
+        if (t < 0) {
139
+            memset(&t, 0, sizeof(time_t));
140
+            return t;
141
+        } else {
142
+            return t;
143
+        }
144
+    } else {
145
+        memset(&t, 0, sizeof(time_t));
146
+        return t;
147
+    }
148
 }
149
 
150
 
151
@@ -365,83 +398,14 @@ parse_weather(xmlNode *cur_node,
152
 }
153
 
154
 
155
-static void
156
-parse_astro_location(xmlNode *cur_node,
157
-                     xml_astro *astro)
158
-{
159
-    xmlNode *child_node;
160
-    gchar *sunrise, *sunset, *moonrise, *moonset;
161
-    gchar *never_rises, *never_sets;
162
-
163
-    for (child_node = cur_node->children; child_node;
164
-         child_node = child_node->next) {
165
-        if (NODE_IS_TYPE(child_node, "sun")) {
166
-            never_rises = PROP(child_node, "never_rise");
167
-            if (never_rises &&
168
-                (!strcmp(never_rises, "true") ||
169
-                 !strcmp(never_rises, "1")))
170
-                astro->sun_never_rises = TRUE;
171
-            else
172
-                astro->sun_never_rises = FALSE;
173
-            xmlFree(never_rises);
174
-
175
-            never_sets = PROP(child_node, "never_set");
176
-            if (never_sets &&
177
-                (!strcmp(never_sets, "true") ||
178
-                 !strcmp(never_sets, "1")))
179
-                astro->sun_never_sets = TRUE;
180
-            else
181
-                astro->sun_never_sets = FALSE;
182
-            xmlFree(never_sets);
183
-
184
-            sunrise = PROP(child_node, "rise");
185
-            astro->sunrise = parse_timestring(sunrise, NULL, FALSE);
186
-            xmlFree(sunrise);
187
-
188
-            sunset = PROP(child_node, "set");
189
-            astro->sunset = parse_timestring(sunset, NULL, FALSE);
190
-            xmlFree(sunset);
191
-        }
192
-
193
-        if (NODE_IS_TYPE(child_node, "moon")) {
194
-            never_rises = PROP(child_node, "never_rise");
195
-            if (never_rises &&
196
-                (!strcmp(never_rises, "true") ||
197
-                 !strcmp(never_rises, "1")))
198
-                astro->moon_never_rises = TRUE;
199
-            else
200
-                astro->moon_never_rises = FALSE;
201
-            xmlFree(never_rises);
202
-
203
-            never_sets = PROP(child_node, "never_set");
204
-            if (never_sets &&
205
-                (!strcmp(never_sets, "true") ||
206
-                 !strcmp(never_sets, "1")))
207
-                astro->moon_never_sets = TRUE;
208
-            else
209
-                astro->moon_never_sets = FALSE;
210
-            xmlFree(never_sets);
211
-
212
-            moonrise = PROP(child_node, "rise");
213
-            astro->moonrise = parse_timestring(moonrise, NULL, FALSE);
214
-            xmlFree(moonrise);
215
-
216
-            moonset = PROP(child_node, "set");
217
-            astro->moonset = parse_timestring(moonset, NULL, FALSE);
218
-            xmlFree(moonset);
219
-
220
-            astro->moon_phase = PROP(child_node, "phase");
221
-        }
222
-    }
223
-}
224
-
225
-
226
 static xml_astro *
227
 parse_astro_time(xmlNode *cur_node)
228
 {
229
     xmlNode *child_node;
230
     xml_astro *astro;
231
-    gchar *date;
232
+    gchar *date, *sunrise, *sunset, *moonrise, *moonset;
233
+    gboolean sun_rises = FALSE, sun_sets = FALSE;
234
+    gboolean moon_rises = FALSE, moon_sets = FALSE;
235
 
236
     astro = g_slice_new0(xml_astro);
237
     if (G_UNLIKELY(astro == NULL))
238
@@ -452,15 +416,61 @@ parse_astro_time(xmlNode *cur_node)
239
     xmlFree(date);
240
 
241
     for (child_node = cur_node->children; child_node;
242
-         child_node = child_node->next)
243
-        if (NODE_IS_TYPE(child_node, "location"))
244
-            parse_astro_location(child_node, astro);
245
+         child_node = child_node->next) {
246
+        if (child_node->type == XML_ELEMENT_NODE) {
247
+            if (NODE_IS_TYPE(child_node, "sunrise")) {
248
+                sunrise = remove_timezone_offset(PROP(child_node, "time"));
249
+                astro->sunrise = parse_timestring(sunrise, NULL, FALSE);
250
+                xmlFree(sunrise);
251
+                sun_rises = TRUE;
252
+            }
253
+
254
+            if (NODE_IS_TYPE(child_node, "moonset")) {
255
+                moonset = remove_timezone_offset(PROP(child_node, "time"));
256
+                astro->moonset = parse_timestring(moonset, NULL, FALSE);
257
+                xmlFree(moonset);
258
+                moon_sets = TRUE;
259
+            }
260
+
261
+            if (NODE_IS_TYPE(child_node, "sunset")) {
262
+                sunset = remove_timezone_offset(PROP(child_node, "time"));
263
+                astro->sunset = parse_timestring(sunset, NULL, FALSE);
264
+                xmlFree(sunset);
265
+                sun_sets = TRUE;
266
+            }
267
+
268
+            if (NODE_IS_TYPE(child_node, "moonrise")) {
269
+                moonrise = remove_timezone_offset(PROP(child_node, "time"));
270
+                astro->moonrise = parse_timestring(moonrise, NULL, FALSE);
271
+                xmlFree(moonrise);
272
+                moon_rises = TRUE;
273
+            }
274
+        }
275
+    }
276
+
277
+    if (sun_rises)
278
+        astro->sun_never_rises = FALSE;
279
+    else
280
+        astro->sun_never_rises = TRUE;
281
+    if (sun_sets)
282
+        astro->sun_never_sets = FALSE;
283
+    else
284
+        astro->sun_never_sets = TRUE;
285
+
286
+    if (moon_rises)
287
+        astro->moon_never_rises = FALSE;
288
+    else
289
+        astro->moon_never_rises = TRUE;
290
+    if (moon_sets)
291
+        astro->moon_never_sets = FALSE;
292
+    else
293
+        astro->moon_never_sets = TRUE;
294
     return astro;
295
 }
296
 
297
 
298
 /*
299
- * Look at https://api.met.no/weatherapi/sunrise/1.1/schema for information
300
+ * Look at https://api.met.no/weatherapi/sunrise/2.0/schema for information
301
  * of elements and attributes to expect.
302
  */
303
 gboolean
304
@@ -475,7 +485,8 @@ parse_astrodata(xmlNode *cur_node,
305
         return FALSE;
306
 
307
     g_assert(cur_node != NULL);
308
-    if (G_UNLIKELY(cur_node == NULL || !NODE_IS_TYPE(cur_node, "astrodata")))
309
+    if (G_UNLIKELY(cur_node == NULL ||
310
+        !NODE_IS_TYPE(cur_node, "location")))
311
         return FALSE;
312
 
313
     for (child_node = cur_node->children; child_node;
314
diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
315
index bd9b05b..44d1874 100644
316
--- panel-plugin/weather-summary.c
317
+++ panel-plugin/weather-summary.c
318
@@ -417,12 +417,12 @@ create_summary_tab(plugin_data *data)
319
             value = g_strdup(_("\tSunset:\t\tThe sun never sets today.\n"));
320
             APPEND_TEXT_ITEM_REAL(value);
321
         } else {
322
-            sunrise = format_date(data->current_astro->sunrise, NULL, TRUE);
323
+            sunrise = format_date(data->current_astro->sunrise, NULL, FALSE);
324
             value = g_strdup_printf(_("\tSunrise:\t\t%s\n"), sunrise);
325
             g_free(sunrise);
326
             APPEND_TEXT_ITEM_REAL(value);
327
 
328
-            sunset = format_date(data->current_astro->sunset, NULL, TRUE);
329
+            sunset = format_date(data->current_astro->sunset, NULL, FALSE);
330
             value = g_strdup_printf(_("\tSunset:\t\t%s\n\n"), sunset);
331
             g_free(sunset);
332
             APPEND_TEXT_ITEM_REAL(value);
333
@@ -445,12 +445,12 @@ create_summary_tab(plugin_data *data)
334
                 g_strdup(_("\tMoonset:\tThe moon never sets today.\n"));
335
             APPEND_TEXT_ITEM_REAL(value);
336
         } else {
337
-            moonrise = format_date(data->current_astro->moonrise, NULL, TRUE);
338
+            moonrise = format_date(data->current_astro->moonrise, NULL, FALSE);
339
             value = g_strdup_printf(_("\tMoonrise:\t%s\n"), moonrise);
340
             g_free(moonrise);
341
             APPEND_TEXT_ITEM_REAL(value);
342
 
343
-            moonset = format_date(data->current_astro->moonset, NULL, TRUE);
344
+            moonset = format_date(data->current_astro->moonset, NULL, FALSE);
345
             value = g_strdup_printf(_("\tMoonset:\t%s\n"), moonset);
346
             g_free(moonset);
347
             APPEND_TEXT_ITEM_REAL(value);
348
@@ -699,13 +699,13 @@ forecast_day_header_tooltip_text(xml_astro *astro)
349
                                     "Sunset: The sun never sets this day."
350
                                     "</small></tt>\n"));
351
         else {
352
-            sunrise = format_date(astro->sunrise, NULL, TRUE);
353
+            sunrise = format_date(astro->sunrise, NULL, FALSE);
354
             g_string_append_printf(text, _("<tt><small>"
355
                                            "Sunrise: %s"
356
                                            "</small></tt>\n"), sunrise);
357
             g_free(sunrise);
358
 
359
-            sunset = format_date(astro->sunset, NULL, TRUE);
360
+            sunset = format_date(astro->sunset, NULL, FALSE);
361
             g_string_append_printf(text, _("<tt><small>"
362
                                            "Sunset:  %s"
363
                                            "</small></tt>\n\n"), sunset);
364
@@ -732,13 +732,13 @@ forecast_day_header_tooltip_text(xml_astro *astro)
365
                               "Moonset: The moon never sets this day."
366
                               "</small></tt>\n"));
367
         else {
368
-            moonrise = format_date(astro->moonrise, NULL, TRUE);
369
+            moonrise = format_date(astro->moonrise, NULL, FALSE);
370
             g_string_append_printf(text, _("<tt><small>"
371
                                            "Moonrise: %s"
372
                                            "</small></tt>\n"), moonrise);
373
             g_free(moonrise);
374
 
375
-            moonset = format_date(astro->moonset, NULL, TRUE);
376
+            moonset = format_date(astro->moonset, NULL, FALSE);
377
             g_string_append_printf(text, _("<tt><small>"
378
                                            "Moonset:  %s"
379
                                            "</small></tt>"), moonset);
380
@@ -1084,10 +1084,10 @@ update_summary_subtitle(plugin_data *data)
381
     time(&now_t);
382
 #ifdef HAVE_UPOWER_GLIB
383
     if (data->upower_on_battery)
384
-        date_format = "%Y-%m-%d %H:%M %z (%Z)";
385
+        date_format = "%Y-%m-%d %H:%M:%S (%Z)";
386
     else
387
 #endif
388
-        date_format = "%Y-%m-%d %H:%M:%S %z (%Z)";
389
+        date_format = "%Y-%m-%d %H:%M:%S (%Z)";
390
     date = format_date(now_t, date_format, TRUE);
391
     title = g_strdup_printf("%s\n%s", data->location_name, date);
392
     g_free(date);
393
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
394
index 752de48..c398381 100644
395
--- panel-plugin/weather.c
396
+++ panel-plugin/weather.c
397
@@ -26,6 +26,9 @@
398
 #include <libxfce4util/libxfce4util.h>
399
 #include <libxfce4ui/libxfce4ui.h>
400
 
401
+#include <libxml/parser.h>
402
+#include <libxml/tree.h>
403
+
404
 #include "weather-parsers.h"
405
 #include "weather-data.h"
406
 #include "weather.h"
407
@@ -47,12 +50,6 @@
408
 #define CONN_RETRY_INTERVAL_SMALL (10)
409
 #define CONN_RETRY_INTERVAL_LARGE (10 * 60)
410
 
411
-/* met.no sunrise API returns data for up to 30 days in the future and
412
-   will return an error page if too many days are requested. Let's
413
-   play it safe and request fewer than that, since we can only get a
414
-   10 days forecast too. */
415
-#define ASTRODATA_MAX_DAYS 25
416
-
417
 /* power saving update interval in seconds used as a precaution to
418
    deal with suspend/resume events etc., when nothing needs to be
419
    updated earlier: */
420
@@ -81,6 +78,7 @@
421
     g_free(locname);                            \
422
     g_free(lat);                                \
423
     g_free(lon);                                \
424
+    g_free(offset);                             \
425
     if (keyfile)                                \
426
         g_key_file_free(keyfile);
427
 
428
@@ -269,6 +267,19 @@ update_timezone(plugin_data *data)
429
 }
430
 
431
 
432
+void
433
+update_offset(plugin_data *data)
434
+{
435
+    GDateTime *dt;
436
+
437
+    dt = g_date_time_new_now_local();
438
+    if (G_LIKELY(data->offset))
439
+        g_free(data->offset);
440
+
441
+    data->offset = g_date_time_format(dt, "%:z");
442
+}
443
+
444
+
445
 void
446
 update_icon(plugin_data *data)
447
 {
448
@@ -481,7 +492,7 @@ cb_astro_update(SoupSession *session,
449
 {
450
     plugin_data *data = user_data;
451
     xmlDoc *doc;
452
-    xmlNode *root_node;
453
+    xmlNode *root_node, *child_node;
454
     time_t now_t;
455
     gboolean parsing_error = TRUE;
456
 
457
@@ -492,13 +503,19 @@ cb_astro_update(SoupSession *session,
458
         doc = get_xml_document(msg);
459
         if (G_LIKELY(doc)) {
460
             root_node = xmlDocGetRootElement(doc);
461
-            if (G_LIKELY(root_node))
462
-                if (parse_astrodata(root_node, data->astrodata)) {
463
-                    /* schedule next update */
464
-                    data->astro_update->attempt = 0;
465
-                    data->astro_update->last = now_t;
466
-                    parsing_error = FALSE;
467
+            if (G_LIKELY(root_node)) {
468
+                for (child_node = root_node->children; child_node;
469
+                     child_node = child_node->next) {
470
+                    if (child_node->type == XML_ELEMENT_NODE) {
471
+                        if (parse_astrodata(child_node, data->astrodata)) {
472
+                            /* schedule next update */
473
+                            data->astro_update->attempt = 0;
474
+                            data->astro_update->last = now_t;
475
+                            parsing_error = FALSE;
476
+                        }
477
+                    }
478
                 }
479
+            }
480
             xmlFreeDoc(doc);
481
         }
482
         if (parsing_error)
483
@@ -580,8 +597,8 @@ update_handler(plugin_data *data)
484
 {
485
     gchar *url;
486
     gboolean night_time;
487
-    time_t now_t, end_t;
488
-    struct tm now_tm, end_tm;
489
+    time_t now_t;
490
+    struct tm now_tm;
491
 
492
     g_assert(data != NULL);
493
     if (G_UNLIKELY(data == NULL))
494
@@ -616,26 +633,22 @@ update_handler(plugin_data *data)
495
         data->astro_update->next = time_calc_hour(now_tm, 1);
496
         data->astro_update->started = TRUE;
497
 
498
-        /* calculate date range for request */
499
-        end_t = time_calc_day(now_tm, ASTRODATA_MAX_DAYS);
500
-        end_tm = *localtime(&end_t);
501
-
502
         /* build url */
503
-        url = g_strdup_printf("https://api.met.no/weatherapi/sunrise/1.1/?"
504
-                              "lat=%s;lon=%s;"
505
-                              "from=%04d-%02d-%02d;"
506
-                              "to=%04d-%02d-%02d",
507
+        url = g_strdup_printf("https://api.met.no/weatherapi"
508
+                              "/sunrise/2.0/?lat=%s&lon=%s&"
509
+                              "date=%04d-%02d-%02d&"
510
+                              "offset=%s&days=%u",
511
                               data->lat, data->lon,
512
                               now_tm.tm_year + 1900,
513
                               now_tm.tm_mon + 1,
514
                               now_tm.tm_mday,
515
-                              end_tm.tm_year + 1900,
516
-                              end_tm.tm_mon + 1,
517
-                              end_tm.tm_mday);
518
+                              data->offset,
519
+                              data->forecast_days);
520
 
521
         /* start receive thread */
522
         g_message(_("getting %s"), url);
523
-        weather_http_queue_request(data->session, url, cb_astro_update, data);
524
+        weather_http_queue_request(data->session, url,
525
+                                   cb_astro_update, data);
526
         g_free(url);
527
     }
528
 
529
@@ -647,10 +660,10 @@ update_handler(plugin_data *data)
530
         data->weather_update->started = TRUE;
531
 
532
         /* build url */
533
-        url =
534
-            g_strdup_printf("https://api.met.no/weatherapi"
535
-                            "/locationforecastlts/1.3/?lat=%s;lon=%s;msl=%d",
536
-                            data->lat, data->lon, data->msl);
537
+        url = g_strdup_printf("https://api.met.no/weatherapi"
538
+                              "/locationforecastlts/1.3/?lat=%s&lon=%s&"
539
+                              "msl=%d",
540
+                              data->lat, data->lon, data->msl);
541
 
542
         /* start receive thread */
543
         g_message(_("getting %s"), url);
544
@@ -707,7 +720,7 @@ schedule_next_wakeup(plugin_data *data)
545
 
546
     next_day_t = day_at_midnight(now_t, 1);
547
     diff = difftime(next_day_t, now_t);
548
-	data->next_wakeup_reason = "current astro data update";
549
+    data->next_wakeup_reason = "current astro data update";
550
     SCHEDULE_WAKEUP_COMPARE(data->astro_update->next,
551
                             "astro data download");
552
     SCHEDULE_WAKEUP_COMPARE(data->weather_update->next,
553
@@ -853,6 +866,12 @@ xfceweather_read_config(XfcePanelPlugin *plugin,
554
         data->timezone = g_strdup(value);
555
     }
556
 
557
+    value = xfce_rc_read_entry(rc, "offset", NULL);
558
+    if (value) {
559
+        g_free(data->offset);
560
+        data->offset = g_strdup(value);
561
+    }
562
+
563
     value = xfce_rc_read_entry(rc, "geonames_username", NULL);
564
     if (value) {
565
         g_free(data->geonames_username);
566
@@ -975,6 +994,8 @@ xfceweather_write_config(XfcePanelPlugin *plugin,
567
 
568
     xfce_rc_write_entry(rc, "timezone", data->timezone);
569
 
570
+    xfce_rc_write_entry(rc, "offset", data->offset);
571
+
572
     if (data->geonames_username)
573
         xfce_rc_write_entry(rc, "geonames_username", data->geonames_username);
574
 
575
@@ -1076,6 +1097,7 @@ write_cache_file(plugin_data *data)
576
     CACHE_APPEND("location_name=%s\n", data->location_name);
577
     CACHE_APPEND("lat=%s\n", data->lat);
578
     CACHE_APPEND("lon=%s\n", data->lon);
579
+    CACHE_APPEND("offset=%s\n", data->offset);
580
     g_string_append_printf(out, "msl=%d\n", data->msl);
581
     g_string_append_printf(out, "timeslices=%d\n", wd->timeslices->len);
582
     if (G_LIKELY(data->weather_update)) {
583
@@ -1190,7 +1212,7 @@ read_cache_file(plugin_data *data)
584
     xml_location *loc = NULL;
585
     xml_astro *astro = NULL;
586
     time_t now_t = time(NULL), cache_date_t;
587
-    gchar *file, *locname = NULL, *lat = NULL, *lon = NULL, *group = NULL;
588
+    gchar *file, *locname = NULL, *lat = NULL, *lon = NULL, *group = NULL, *offset = NULL;
589
     gchar *timestring;
590
     gint msl, num_timeslices = 0, i, j;
591
 
592
@@ -1225,7 +1247,8 @@ read_cache_file(plugin_data *data)
593
     locname = g_key_file_get_string(keyfile, group, "location_name", NULL);
594
     lat = g_key_file_get_string(keyfile, group, "lat", NULL);
595
     lon = g_key_file_get_string(keyfile, group, "lon", NULL);
596
-    if (locname == NULL || lat == NULL || lon == NULL) {
597
+    offset = g_key_file_get_string(keyfile, group, "offset", NULL);
598
+    if (locname == NULL || lat == NULL || lon == NULL || offset == NULL) {
599
         CACHE_FREE_VARS();
600
         weather_debug("Required values are missing in the cache file, "
601
                       "reading cache file aborted.");
602
@@ -1236,7 +1259,8 @@ read_cache_file(plugin_data *data)
603
         num_timeslices = g_key_file_get_integer(keyfile, group,
604
                                                 "timeslices", &err);
605
     if (err || strcmp(lat, data->lat) || strcmp(lon, data->lon) ||
606
-        msl != data->msl || num_timeslices < 1) {
607
+        strcmp(offset, data->offset) || msl != data->msl ||
608
+        num_timeslices < 1) {
609
         CACHE_FREE_VARS();
610
         weather_debug("The required values are not present in the cache file "
611
                       "or do not match the current plugin data. Reading "
612
@@ -1404,6 +1428,9 @@ update_weatherdata_with_reset(plugin_data *data)
613
     /* set location timezone */
614
     update_timezone(data);
615
 
616
+    /* set the offset of timezone */
617
+    update_offset(data);
618
+
619
     /* clear update times */
620
     init_update_infos(data);
621
 
622
@@ -1709,9 +1736,9 @@ weather_get_tooltip_text(const plugin_data *data)
623
             sunval = g_strdup(_("The sun never sets today."));
624
         } else {
625
             sunrise = format_date(data->current_astro->sunrise,
626
-                                  "%H:%M:%S", TRUE);
627
+                                  "%H:%M:%S", FALSE);
628
             sunset = format_date(data->current_astro->sunset,
629
-                                 "%H:%M:%S", TRUE);
630
+                                 "%H:%M:%S", FALSE);
631
             sunval =
632
                 g_strdup_printf(_("The sun rises at %s and sets at %s."),
633
                                 sunrise, sunset);
634
@@ -1999,6 +2026,7 @@ xfceweather_free(XfcePanelPlugin *plugin,
635
     g_free(data->location_name);
636
     g_free(data->scrollbox_font);
637
     g_free(data->timezone);
638
+    g_free(data->offset);
639
     g_free(data->timezone_initial);
640
     g_free(data->geonames_username);
641
 
642
@@ -2170,6 +2198,7 @@ weather_construct(XfcePanelPlugin *plugin)
643
 
644
     xfceweather_read_config(plugin, data);
645
     update_timezone(data);
646
+    update_offset(data);
647
     read_cache_file(data);
648
     update_current_conditions(data, TRUE);
649
     scrollbox_set_visible(data);
650
diff --git a/panel-plugin/weather.h b/panel-plugin/weather.h
651
index b1849a9..31ab9fb 100644
652
--- panel-plugin/weather.h
653
+++ panel-plugin/weather.h
654
@@ -114,6 +114,7 @@ typedef struct {
655
     gchar *lon;
656
     gint msl;
657
     gchar *timezone;
658
+    gchar *offset;
659
     gchar *timezone_initial;
660
     gint cache_file_max_age;
661
     gboolean night_time;
662
@@ -144,6 +145,8 @@ gchar *get_cache_directory(void);
663
 
664
 void update_timezone(plugin_data *data);
665
 
666
+void update_offset(plugin_data *data);
667
+
668
 void update_icon(plugin_data *data);
669
 
670
 void update_scrollbox(plugin_data *data,
671
-- 
672
2.20.1
673

Return to bug 236735