diff options
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 */ |