ckgt / NemaTode

C++ 11 NMEA Parser and GPS Interface
Other
134 stars 79 forks source link

GPSTimestamp::getTime() has time shift in the opposite direction of the system time wrt UTC #6

Open hicklin opened 5 years ago

hicklin commented 5 years ago

The mktime function used to convert the tm struct to time_t (seconds since Jan 1, 1970) assumes that the tm struct time is in local time. Hence, in the instance that the system time is not equal to UTC, the GPS time returned is shifted by the timezone in the opposite direction.

hicklin commented 5 years ago

I have fixed the issue in my fork by subtracting the timezone in seconds from the returned time_t in line 175 of GPSFix.cpp.

return mktime(&t) - timezone;