mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-01 17:49:02 +00:00
tstime/mono: make json.Unmarshal of a zero time.Time yield a zero Time
This was the proximate cause of #2579. #2582 is a deeper fix, but this will remain as a footgun, so may as well fix it too. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
committed by
Josh Bleecher Snyder
parent
f3c96df162
commit
f013960d87
@@ -121,6 +121,10 @@ func (t *Time) UnmarshalJSON(data []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if tt.IsZero() {
|
||||
*t = 0
|
||||
return nil
|
||||
}
|
||||
*t = Now().Add(-time.Since(tt))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user