Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClockTimezone ¶
GetClockTimezone returns timezone of given clock. It is useful for wire dependency injection.
func LoadLocation ¶
LoadLocation loads the timezone with the given name.
func Local ¶
Local returns the local timezone with full name. In comparison to time.Local, this function returns the full name of the timezone. Example:
time.Local.String() -> "Local" Local().String() -> "Europe/Berlin" (or whatever your local timezone is)
This is useful in cases where a session is timezone oriented.
Types ¶
type Clock ¶
type Clock interface { // Now returns the current time. Now() time.Time // Unix returns the current time in unix format. Unix() int64 // UnixNano returns the current time in unix format. UnixNano() int64 // Location returns the current location. Location() *time.Location // Since returns the time elapsed since t. Since(t time.Time) time.Duration // Until returns the time until t. Until(t time.Time) time.Duration }
Clock is an interface that gives access to the current time.
type ZonedClock ¶
type ZonedClock struct {
// contains filtered or unexported fields
}
ZonedClock is the default implementation of the Clock interface.
func NewLocalClock ¶
func NewLocalClock() (*ZonedClock, error)
NewLocalClock creates a new ZonedClock.
func NewZonedClock ¶
func NewZonedClock(loc *time.Location) *ZonedClock
NewZonedClock creates a new ZonedClock.
func (*ZonedClock) Location ¶
func (c *ZonedClock) Location() *time.Location
Location returns the current location.
func (*ZonedClock) Since ¶
func (c *ZonedClock) Since(t time.Time) time.Duration
Since returns the time elapsed since t.
func (*ZonedClock) Unix ¶
func (c *ZonedClock) Unix() int64
Unix returns the current time in unix format.
func (*ZonedClock) UnixNano ¶
func (c *ZonedClock) UnixNano() int64
UnixNano returns the current time in unix format.