Small fixes to minmea_gettime
* Handle four digit years provided by ZDA in minmea_gettime * Assume GPS epoch to allow dates prior 2000 to be parsed
This commit is contained in:
parent
dbf51f03c5
commit
486da2bb5b
6
minmea.c
6
minmea.c
@ -619,7 +619,11 @@ int minmea_gettime(struct timespec *ts, const struct minmea_date *date, const st
|
|||||||
|
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
memset(&tm, 0, sizeof(tm));
|
memset(&tm, 0, sizeof(tm));
|
||||||
tm.tm_year = 2000 + date->year - 1900;
|
tm.tm_year = date->year % 100; // ZDA parser stores 4 digit year, filter centuries here so raw information is still preserved for user.
|
||||||
|
if (tm.tm_year < 80) // GPS epoch begins 1980, assume a year range of 1980 to 2079 for the library.
|
||||||
|
{
|
||||||
|
tm.tm_year += 2000 - 1900;
|
||||||
|
}
|
||||||
tm.tm_mon = date->month - 1;
|
tm.tm_mon = date->month - 1;
|
||||||
tm.tm_mday = date->day;
|
tm.tm_mday = date->day;
|
||||||
tm.tm_hour = time_->hours;
|
tm.tm_hour = time_->hours;
|
||||||
|
Loading…
Reference in New Issue
Block a user