15 lines
383 B
Go
15 lines
383 B
Go
package clock
|
|
|
|
import "time"
|
|
|
|
// Instant is a UTC point represented as Unix milliseconds.
|
|
type Instant int64
|
|
|
|
func (i Instant) Valid() bool { return i > 0 }
|
|
|
|
func NowInstant() Instant { return FromTime(time.Now().UTC()) }
|
|
|
|
func FromTime(value time.Time) Instant { return Instant(value.UTC().UnixMilli()) }
|
|
|
|
func (i Instant) Time() time.Time { return time.UnixMilli(int64(i)).UTC() }
|