tmtime: Canonical, some comments (#2312)

This commit is contained in:
Ethan Buchman
2018-09-04 04:20:58 -04:00
committed by Anton Kaliaev
parent 166fd82b70
commit eabb1ece8e
4 changed files with 15 additions and 5 deletions

View File

@ -5,16 +5,23 @@ import (
"time"
)
// Now returns UTC time rounded since the zero time.
// Now returns the current time in UTC with no monotonic component.
func Now() time.Time {
return time.Now().Round(0).UTC()
return Canonical(time.Now())
}
// Canonical returns UTC time with no monotonic component.
func Canonical(t time.Time) time.Time {
return t.Round(0).UTC()
}
// WeightedTime for computing a median.
type WeightedTime struct {
Time time.Time
Weight int64
}
// NewWeightedTime with time and weight.
func NewWeightedTime(time time.Time, weight int64) *WeightedTime {
return &WeightedTime{
Time: time,