Fix gps time calculation (#785)

* Change test case to match the date patterns where the bug reproduces
* Fix RMC date and time calculation
This commit is contained in:
Russel Hunter Yukawa
2025-08-13 16:39:18 +09:00
committed by GitHub
parent 303ec94529
commit a31ba26a6c
2 changed files with 7 additions and 4 deletions
+4 -1
View File
@@ -96,7 +96,10 @@ func (parser *Parser) Parse(sentence string) (Fix, error) {
fix.Speed = findSpeed(fields[7])
fix.Heading = findHeading(fields[8])
date := findDate(fields[9])
fix.Time = fix.Time.AddDate(date.Year(), int(date.Month()), date.Day())
fix.Time = date.Add(time.Duration(fix.Time.Hour())*time.Hour +
time.Duration(fix.Time.Minute())*time.Minute +
time.Duration(fix.Time.Second())*time.Second +
time.Duration(fix.Time.Nanosecond())*time.Nanosecond)
return fix, nil
}