We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2bbc360 commit 31d7544Copy full SHA for 31d7544
rtcm3/time.go
@@ -13,6 +13,7 @@ func DF004(e uint32) time.Time {
13
}
14
15
func DF004Time(e uint32, start time.Time) time.Time {
16
+ // TODO: GpsLeapSeconds should take a time to return leap seconds as at that time
17
start = start.Add(rtcm.GpsLeapSeconds()) // UTC to GPS time
18
sow := start.Truncate(time.Hour*24).AddDate(0, 0, -int(start.Weekday()))
19
tow := time.Duration(e) * time.Millisecond
@@ -21,10 +22,10 @@ func DF004Time(e uint32, start time.Time) time.Time {
21
22
23
// BeiDou Epoch Time (TOW)
24
func DF427(e uint32, start time.Time) time.Time {
- start = start.Add(rtcm.GpsLeapSeconds()) // UTC to GPS time
25
- sow := start.Truncate(time.Hour*24).AddDate(0, 0, -int(start.Weekday())).Add(-14 * time.Second)
+ start = start.Add(rtcm.GpsLeapSeconds() - 14*time.Second) // UTC to GPS time
26
+ sow := start.Truncate(time.Hour*24).AddDate(0, 0, -int(start.Weekday()))
27
- return sow.Add(-(rtcm.GpsLeapSeconds())).Add(tow)
28
+ return sow.Add(-(rtcm.GpsLeapSeconds())).Add(tow + 14*time.Second)
29
30
31
// GPS Epoch Time 1s
rtcm3/time_test.go
@@ -20,6 +20,23 @@ func TestDF034(t *testing.T) {
20
+func TestDF427(t *testing.T) {
+ refTimeG0 := time.Date(2023, 2, 25, 23, 59, 42, 0, time.UTC)
+ if time := rtcm3.DF427(604786000, refTimeG0); time != refTimeG0 {
+ t.Errorf("DF427 time incorrect at GPS 0: %v, expected %v", time, refTimeG0)
+ }
+
+ refTimeB0 := time.Date(2023, 2, 25, 23, 59, 56, 0, time.UTC)
+ if time := rtcm3.DF427(0, refTimeB0); time != refTimeB0 {
+ t.Errorf("DF427 time incorrect at BeiDou 0: %v, expected %v", time, refTimeB0)
32
33
34
+ refTimeX := time.Date(2019, 2, 8, 00, 44, 44, 0, time.UTC)
35
+ if time := rtcm3.DF034(13484000, refTimeX); time != refTimeX {
36
+ t.Errorf("DF427 time incorrect: %v, expected %v", time, refTimeX)
37
38
+}
39
40
func TestGlonassTimeMSM(t *testing.T) {
41
midweek := time.Date(2019, 3, 28, 4, 2, 9, 0, time.UTC)
42
if time := rtcm3.GlonassTimeMSM(562199912, midweek); time != midweek {
0 commit comments