From 7497b7707365d76c1ba7a06ac0a9b9c3d9b45cec Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Wed, 6 Jul 2022 11:12:06 -0400 Subject: [PATCH] fix: use time.Time instead of time.Duration --- rln/types.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rln/types.go b/rln/types.go index 7c9518d..5e2d460 100644 --- a/rln/types.go +++ b/rln/types.go @@ -242,9 +242,8 @@ func (e Epoch) Uint64() uint64 { // CalcEpoch gets time `t` as `float64` with subseconds resolution in the fractional part // and returns its corresponding rln `Epoch` value -func CalcEpoch(t time.Duration) Epoch { - e := uint64(t / EPOCH_UNIT_SECONDS) - return ToEpoch(e) +func CalcEpoch(t time.Time) Epoch { + return ToEpoch(uint64(t.Unix())) } // GetCurrentEpoch gets the current rln Epoch time @@ -258,3 +257,7 @@ func Diff(e1, e2 Epoch) int64 { epoch2 := e2.Uint64() return int64(epoch1) - int64(epoch2) } + +func (e Epoch) Time() time.Time { + return time.Unix(int64(e.Uint64()), 0) +}