summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2021-03-03 09:45:16 +0000
committerAlastair Poole <netstar@gmail.com>2021-03-03 09:45:16 +0000
commit1b3ec251525b8ff57ca858bdd5256099b23bd06e (patch)
tree06719066b65c5544fcef1b320a9b2e7f1ebfcbc8
parentea163b7813f4682f16c9f37cbed21f877ebb7c32 (diff)
mod: last updated.
-rw-r--r--src/e_mod_main.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/e_mod_main.c b/src/e_mod_main.c
index 3e4bd73..90433e1 100644
--- a/src/e_mod_main.c
+++ b/src/e_mod_main.c
@@ -45,6 +45,7 @@ struct _Instance
45 Ecore_Event_Handler *url_data_handler; 45 Ecore_Event_Handler *url_data_handler;
46 Ecore_Event_Handler *url_complete_handler; 46 Ecore_Event_Handler *url_complete_handler;
47 47
48 const char *update_time;
48 struct 49 struct
49 { 50 {
50 int temp; 51 int temp;
@@ -195,6 +196,8 @@ _gc_shutdown(E_Gadcon_Client *gcc)
195 if (inst->area) 196 if (inst->area)
196 eina_stringshare_del(inst->area); 197 eina_stringshare_del(inst->area);
197 eina_strbuf_free(inst->buffer); 198 eina_strbuf_free(inst->buffer);
199 if (inst->update_time)
200 eina_stringshare_del(inst->update_time);
198 201
199 inst->url = NULL; 202 inst->url = NULL;
200 forecasts_config->instances = 203 forecasts_config->instances =
@@ -558,6 +561,20 @@ _forecasts_url_complete(void *data, int type EINA_UNUSED, void *event)
558 return EINA_FALSE; 561 return EINA_FALSE;
559} 562}
560 563
564static void
565_timestamp_local(const char *timestamp, char *buf, size_t len)
566{
567 struct tm tm_in;
568 struct tm *tm_out;
569 time_t t;
570
571 memset(&tm_in, 0, sizeof(struct tm));
572 strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ", &tm_in);
573 t = mktime(&tm_in);
574 tm_out = localtime(&t);
575 strftime(buf, len - 1, "%Y-%m-%d %H:%M:%S", tm_out);
576}
577
561static struct tm * 578static struct tm *
562_timestamp_time(const char *timestamp) 579_timestamp_time(const char *timestamp)
563{ 580{
@@ -567,9 +584,7 @@ _timestamp_time(const char *timestamp)
567 584
568 memset(&tm_in, 0, sizeof(struct tm)); 585 memset(&tm_in, 0, sizeof(struct tm));
569 strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ", &tm_in); 586 strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ", &tm_in);
570
571 t = mktime(&tm_in); 587 t = mktime(&tm_in);
572
573 tm_out = localtime(&t); 588 tm_out = localtime(&t);
574 589
575 return tm_out; 590 return tm_out;
@@ -621,6 +636,13 @@ _forecasts_parse(void *data)
621 if (!o_root) goto error; 636 if (!o_root) goto error;
622 json_object *o_properties = json_object_object_get(o_root, "properties"); 637 json_object *o_properties = json_object_object_get(o_root, "properties");
623 if (!o_properties) goto error; 638 if (!o_properties) goto error;
639 json_object *o_meta = json_object_object_get(o_properties, "meta");
640 if (!o_meta) goto error;
641 json_object *o_updated = json_object_object_get(o_meta, "updated_at");
642 if (!o_updated) goto error;
643 timestamp = json_object_get_string(o_updated);
644 if (!timestamp) goto error;
645 eina_stringshare_replace(&inst->update_time, timestamp);
624 json_object *o_timeseries = json_object_object_get(o_properties, "timeseries"); 646 json_object *o_timeseries = json_object_object_get(o_properties, "timeseries");
625 if (!o_timeseries) goto error; 647 if (!o_timeseries) goto error;
626 if (json_object_get_type(o_timeseries) != json_type_array) goto error; 648 if (json_object_get_type(o_timeseries) != json_type_array) goto error;
@@ -899,7 +921,7 @@ _forecasts_popup_content_create(Instance *inst)
899{ 921{
900 Evas_Object *base, *bx, *hbx, *fr, *tb, *lb; 922 Evas_Object *base, *bx, *hbx, *fr, *tb, *lb;
901 Evas_Object *rec, *ic, *im; 923 Evas_Object *rec, *ic, *im;
902 char buf[4096]; 924 char buf[2048], tmp[2048];
903 int row = 0; 925 int row = 0;
904 Evas_Coord w, h; 926 Evas_Coord w, h;
905 927
@@ -941,7 +963,13 @@ _forecasts_popup_content_create(Instance *inst)
941 if (h > 160) h = 160; 963 if (h > 160) h = 160;
942 im = e_widget_image_add_from_object(e_comp->evas, ic, w, h); 964 im = e_widget_image_add_from_object(e_comp->evas, ic, w, h);
943 evas_object_show(im); 965 evas_object_show(im);
944 elm_table_pack(tb, im, 0, row++, 2, 1); 966 elm_table_pack(tb, im, 0, row, 2, 1);
967
968 _timestamp_local(inst->update_time, tmp, sizeof(tmp));
969 snprintf(buf, sizeof(buf), D_("<small>Updated: %s</>"), tmp);
970 lb = _lb_add(base, buf);
971 evas_object_size_hint_align_set(lb, 1.0, 0.0);
972 elm_table_pack(tb, lb, 0, row++, 2, 1);
945 973
946 snprintf(buf, sizeof(buf), "<b>%s</>", inst->location); 974 snprintf(buf, sizeof(buf), "<b>%s</>", inst->location);
947 lb = _lb_add(base, buf); 975 lb = _lb_add(base, buf);