fix: use time.Time instead of time.Duration

This commit is contained in:
Richard Ramos 2022-07-06 11:12:06 -04:00
parent 320b2aea16
commit 7497b77073
No known key found for this signature in database
GPG Key ID: BD36D48BC9FFC88C
1 changed files with 6 additions and 3 deletions

View File

@ -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)
}