Skip to content

Commit

Permalink
Merge pull request #473 from patthoyts/pt/with-tz-no
Browse files Browse the repository at this point in the history
Enable building when WITH_TZ=no to disable timezone information.
  • Loading branch information
jpmens authored Jun 16, 2024
2 parents 5f27238 + 020212e commit be7a172
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ void append_card_to_object(JsonNode *obj, char *user, char *device)
json_delete(card);
}

#ifdef WITH_TZ
static void tz_info(JsonNode *json, double lat, double lon, time_t tst)
{
// olog(LOG_DEBUG, "tz_info for (%lf, %lf)", lat, lon);
Expand All @@ -254,6 +255,7 @@ static void tz_info(JsonNode *json, double lat, double lon, time_t tst)
}
}
}
#endif

void append_device_details(JsonNode *userlist, char *user, char *device)
{
Expand All @@ -265,16 +267,19 @@ void append_device_details(JsonNode *userlist, char *user, char *device)

last = json_mkobject();
if (json_copy_from_file(last, path) == TRUE) {
JsonNode *jtst, *jlat, *jlon;
JsonNode *jtst;

if ((jtst = json_find_member(last, "tst")) != NULL) {
json_append_member(last, "isotst", json_mkstring(isotime(jtst->number_)));
json_append_member(last, "disptst", json_mkstring(disptime(jtst->number_)));

#ifdef WITH_TZ
JsonNode *jlat, *jlon;
if ((jlat = json_find_member(last, "lat")) &&
(jlon = json_find_member(last, "lon"))) {
tz_info(last, jlat->number_, jlon->number_, jtst->number_);
}
#endif
}
}

Expand Down Expand Up @@ -773,16 +778,14 @@ static JsonNode *line_to_location(char *line)
* Otherwise determine the TZ name from the tzdatadb.
*/

if ((j = json_find_member(o, "tzname")) != NULL) {
#ifdef WITH_TZ
if ((j = json_find_member(o, "tzname")) != NULL) {
tzname = j->string_;
json_append_member(o, "isolocal", json_mkstring(isolocal(tst, tzname)));
#endif
} else {
#ifdef WITH_TZ
tz_info(o, lat, lon, tst);
#endif
}
#endif

return (o);
}
Expand Down

0 comments on commit be7a172

Please sign in to comment.