From 0f9b06b26618528956ac2343359e0ac0e49f1df0 Mon Sep 17 00:00:00 2001 From: Trek H Date: Thu, 11 Feb 2021 09:58:05 +1030 Subject: [PATCH] revid: only set local clock if it hasn't already been set --- revid/senders.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/revid/senders.go b/revid/senders.go index 619e08b9..8bf10ea0 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -136,13 +136,16 @@ func extractMeta(r string, log func(lvl int8, msg string, args ...interface{})) if err != nil { return nil } - // Extract time from reply - t, err := dec.Int("ts") - if err != nil { - log(logger.Warning, "No timestamp in reply") - } else { - log(logger.Debug, fmt.Sprintf("got timestamp: %v", t)) - mts.RealTime.Set(time.Unix(int64(t), 0)) + // Extract time from reply if mts.Realtime has not been set. + if !mts.RealTime.IsSet() { + t, err := dec.Int("ts") + if err != nil { + log(logger.Warning, "No timestamp in reply") + } else { + log(logger.Debug, fmt.Sprintf("got timestamp: %v", t)) + fmt.Printf("got timestamp: %v, setting\n", t) + mts.RealTime.Set(time.Unix(int64(t), 0)) + } } // Extract location from reply