qbtrade/pkg/util/time.go

17 lines
301 B
Go
Raw Normal View History

2024-06-27 14:42:38 +00:00
package util
import (
"math/rand"
"time"
)
func MillisecondsJitter(d time.Duration, jitterInMilliseconds int) time.Duration {
n := rand.Intn(jitterInMilliseconds)
return d + time.Duration(n)*time.Millisecond
}
func UnixMilli() int64 {
return time.Now().UnixNano() / int64(time.Millisecond)
}