[UAT] Dantracker Time query

David Brooke G6GZH
Mon Feb 27 04:26:10 PST 2017


I seem to recall that the problem is that mypos->tstamp is being treated
as a time structure but is actually just hhmmss represented as a number.

In the absence of a proper solution you might like to try the attached
patch which I came up with some time ago. I never got around to finding
a proper solution but this nasty hack might at least get you something
usable.

It works OK for me in the UK, where we are on UTC (as output by the GPS)
and "daylight saving time" is UTC+1, but will be incorrect in any other
time zone. Therefore you will have to hard code your hour offset and
possibly amend the DST adjustment to suit your TZ.

David G6GZH

-------------- next part --------------
From: David Brooke <github at dbrooke.me.uk>
Date: Mon, 30 Sep 2013 22:50:26 +0000 (+0100)
Subject: Attempt to display UTC (with dst correction) from GPS time
X-Git-Url: http://git.dbrooke.me.uk/gitweb/?p=dantracker.git;a=commitdiff_plain;h=8630b8df50e4abaae5914d24c6c3340eae4beeb1

Attempt to display UTC (with dst correction) from GPS time
---

diff --git a/aprs.c b/aprs.c
index 18ac864..1f8cc20 100644
--- a/aprs.c
+++ b/aprs.c
@@ -1042,13 +1042,23 @@ int display_gps_info(struct state *state)
 {
         char buf[512];
         char timestr[32];
+        struct tm tm;
+        time_t t;
         struct posit *mypos = MYPOS(state);
         const char *status = mypos->qual != 0 ?
                 "Locked" :
                 "<span background='red'>INVALID</span>";
 
+#if 0
         strftime(timestr, sizeof(timestr), "%H:%M:%S",
                  localtime(&mypos->tstamp));
+#endif
+
+
+        t = time(NULL);
+        localtime_r(&t, &tm);
+
+        snprintf(timestr, sizeof(timestr), "%02ld:%02ld:%02ld", ((mypos->tstamp / 10000) + (tm.tm_isdst > 0 ? 1 : 0)) % 24, (mypos->tstamp / 100) % 100, mypos->tstamp % 100);
 
         sprintf(buf, "%7.5f%c %8.5f%c   %s   %s: %2i sats",
                 fabs(mypos->lat), mypos->lat > 0 ? 'N' : 'S',


More information about the UAT mailing list