diff --git a/lib/proto/a_interface_test.go b/lib/proto/a_interface_test.go index 93ea4e0a..c7578204 100644 --- a/lib/proto/a_interface_test.go +++ b/lib/proto/a_interface_test.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "reflect" + "time" "github.com/go-rod/rod/lib/proto" "github.com/go-rod/rod/lib/utils" @@ -73,6 +74,10 @@ func (t T) TimeCodec() { data, err = json.Marshal(datetime) t.E(err) t.Eq(raw, data) + + var sessionExpires proto.TimeSinceEpoch = -1 + var zeroTime time.Time + t.Eq(sessionExpires.Time(), zeroTime) } func (t T) Rect() { diff --git a/lib/proto/a_patch.go b/lib/proto/a_patch.go index 3d5c5d54..f1c8cc05 100644 --- a/lib/proto/a_patch.go +++ b/lib/proto/a_patch.go @@ -16,6 +16,9 @@ type TimeSinceEpoch float64 // Time interface. func (t TimeSinceEpoch) Time() time.Time { + if t == -1 { + return time.Time{} + } return (time.Unix(0, 0)).Add( time.Duration(t * TimeSinceEpoch(time.Second)), )