func (ti *TimeInterval) Duration() time.Duration {
	return ti.end.Sub(ti.start)
}
Duration returns the time.Duration of the TimeInterval.
package utils
import (
	"fmt"
	"math/rand"
	"time"
)
const (
	ErrEndBeforeStart = "end time before start time"
	errWindowTooLargeFmt = "random window equal to or larger than TimeInterval: window %v, interval %v"
)
type TimeInterval struct {
	start time.Time
	end   time.Time
}
func NewTimeInterval(start, end time.Time) (*TimeInterval, error) {
	if end.Before(start) {
		return nil, fmt.Errorf(ErrEndBeforeStart)
	}
	return &TimeInterval{start.UTC(), end.UTC()}, nil
}