mirror of https://github.com/waku-org/go-rln.git
fix: use time.Time instead of time.Duration
This commit is contained in:
parent
320b2aea16
commit
7497b77073
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue