mocktime

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Nanosecond  = realtime.Nanosecond
	Microsecond = realtime.Microsecond
	Millisecond = realtime.Millisecond
	Second      = realtime.Second
	Minute      = realtime.Minute
	Hour        = realtime.Hour
)

Duration constants

View Source
const (
	January   = realtime.January
	February  = realtime.February
	March     = realtime.March
	April     = realtime.April
	May       = realtime.May
	June      = realtime.June
	July      = realtime.July
	August    = realtime.August
	September = realtime.September
	October   = realtime.October
	November  = realtime.November
	December  = realtime.December
)

Month constants

View Source
const (
	Sunday    = realtime.Sunday
	Monday    = realtime.Monday
	Tuesday   = realtime.Tuesday
	Wednesday = realtime.Wednesday
	Thursday  = realtime.Thursday
	Friday    = realtime.Friday
	Saturday  = realtime.Saturday
)

Weekday constants

View Source
const (
	Layout      = "01/02 03:04:05PM '06 -0700" // The reference realtime, in numerical order.
	ANSIC       = "Mon Jan _2 15:04:05 2006"
	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
	RubyDate    = "Mon Jan 02 15:04:05 -0700 2006"
	RFC822      = "02 Jan 06 15:04 MST"
	RFC822Z     = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone
	RFC850      = "Monday, 02-Jan-06 15:04:05 MST"
	RFC1123     = "Mon, 02 Jan 2006 15:04:05 MST"
	RFC1123Z    = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone
	RFC3339     = "2006-01-02T15:04:05Z07:00"
	RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
	Kitchen     = "3:04PM"
	// Handy time stamps.
	Stamp      = "Jan _2 15:04:05"
	StampMilli = "Jan _2 15:04:05.000"
	StampMicro = "Jan _2 15:04:05.000000"
	StampNano  = "Jan _2 15:04:05.000000000"
	DateTime   = "2006-01-02 15:04:05"
	DateOnly   = "2006-01-02"
	TimeOnly   = "15:04:05"
)

Layouts

Variables

View Source
var Local = UTC

Location constants

Functions

func Active

func Active()

func After

func After(d Duration) <-chan Time

func Scale

func Scale() float64

func Set

func Set(now Time)

func SetScale

func SetScale(scale float64)

func Sleep

func Sleep(d Duration)

func Start

func Start()

func Step

func Step(dt Duration)

func Stop

func Stop()

func Tick

func Tick(d Duration) <-chan Time

Types

type Clock

type Clock struct {
	*relativetime.Clock[Time, Duration, *realtime.Timer]
	// contains filtered or unexported fields
}

Inherits methods from relative clock, falling back to real clock for the rest

func NewClock

func NewClock() Clock

func NewClockAt

func NewClockAt(at Time) Clock

type Duration

type Duration = realtime.Duration

func ParseDuration

func ParseDuration(s string) (Duration, error)

func Since

func Since(t Time) Duration

func Until

func Until(t Time) Duration

type Location

type Location = realtime.Location

func FixedZone

func FixedZone(name string, offset int) *Location

func LoadLocation

func LoadLocation(name string) (*Location, error)

func LoadLocationFromTZData

func LoadLocationFromTZData(name string, data []byte) (*Location, error)

type Month

type Month = realtime.Month

type ParseError

type ParseError = realtime.ParseError

type Ticker

type Ticker = relativetime.Ticker[Time, Duration]

func NewTicker

func NewTicker(d Duration) *Ticker

type Time

type Time = realtime.Time

func Date

func Date(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time

func Now

func Now() Time

func Parse

func Parse(layout, value string) (Time, error)

func ParseInLocation

func ParseInLocation(layout, value string, loc *Location) (Time, error)

func Unix

func Unix(sec int64, nsec int64) Time

func UnixMicro

func UnixMicro(usec int64) Time

func UnixMilli

func UnixMilli(msec int64) Time

type Timer

type Timer = relativetime.Timer[Time, Duration]

func AfterFunc

func AfterFunc(d Duration, f func()) *Timer

func NewTimer

func NewTimer(d Duration) *Timer

type Weekday

type Weekday = realtime.Weekday

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL