diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-06-23 11:19:06 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-06-23 11:19:06 -0400 |
commit | a9fc8af665bd726f43edb02d90eb510667e972c7 (patch) | |
tree | 0e4ba7509875d9e7d01e06de56e25695d00be2d8 /timebase.c | |
parent | 3cf6e481245f1fa1ec8b8a4876eae8705a052376 (diff) | |
download | gpsd-a9fc8af665bd726f43edb02d90eb510667e972c7.tar.gz |
Make gpsdecode interpret "Date:" comments. All regression tests pass.
Diffstat (limited to 'timebase.c')
-rw-r--r-- | timebase.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -77,6 +77,10 @@ BSD terms apply: see the file COPYING in the distribution root for details. *****************************************************************************/ +#include <stdlib.h> +#include <string.h> +#include <ctype.h> + #include "gpsd.h" #include "timebase.h" @@ -116,6 +120,25 @@ void gpsd_time_init(struct gps_context_t *context, time_t starttime) } } +void gpsd_set_century(struct gps_device_t *session) +/* + * Interpret "Date: dd mmm yyyy", setting the session context + * century from the year. We do this so the behavior of the + * regression tests won't depend on what century the daemon + * started up in. + */ +{ + unsigned char *cp; + int year; + if (strstr((char *)session->packet.outbuffer, "Date:") != NULL) { + cp = session->packet.outbuffer + strlen((char *)session->packet.outbuffer) - 1; + while (isspace(*cp)) + --cp; + year = atoi((char *)cp - 4); + session->context->century = year - (year % 100); + } +} + #ifdef NMEA_ENABLE timestamp_t gpsd_utc_resolve(/*@in@*/struct gps_device_t *session) /* resolve a UTC date, checking for rollovers */ |