22 lines
415 B
Go
22 lines
415 B
Go
package clock
|
|
|
|
import "time"
|
|
|
|
// Clock exposes basic time operations, primarily for test overrides.
|
|
type Clock interface {
|
|
Now() time.Time
|
|
}
|
|
|
|
// System implements Clock using the system wall clock.
|
|
type System struct{}
|
|
|
|
// Now returns the current UTC time.
|
|
func (System) Now() time.Time {
|
|
return time.Now().UTC()
|
|
}
|
|
|
|
// NewSystem returns a system-backed clock instance.
|
|
func NewSystem() Clock {
|
|
return System{}
|
|
}
|