Documentation
¶
Overview ¶
Package timekit provides time.Time related helpers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClockDeterministic ¶
ClockDeterministic returns the function with the same signature as time.Now and returning time advancing by the given tick with every call no matter how fast or slow you call it.
Example ¶
start := time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC) clk := ClockDeterministic(start, time.Hour) fmt.Println(clk()) fmt.Println(clk()) fmt.Println(clk())
Output: 2022-01-01 00:00:00 +0000 UTC 2022-01-01 01:00:00 +0000 UTC 2022-01-01 02:00:00 +0000 UTC
func ClockFixed ¶
ClockFixed returns the function with the same signature as time.Now which always returns the given time.
Example ¶
clk := ClockFixed(time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC)) fmt.Println(clk()) fmt.Println(clk()) fmt.Println(clk())
Output: 2022-01-01 00:00:00 +0000 UTC 2022-01-01 00:00:00 +0000 UTC 2022-01-01 00:00:00 +0000 UTC
func ClockStartingAt ¶
ClockStartingAt returns the function with the same signature as time.Now and returning time as if the current time was set to the given value.
func TikTak ¶
TikTak returns a deterministic clock advancing one second for each call.
Example ¶
start := time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC) clk := TikTak(start) fmt.Println(clk()) fmt.Println(clk()) fmt.Println(clk())
Output: 2022-01-01 00:00:00 +0000 UTC 2022-01-01 00:00:01 +0000 UTC 2022-01-01 00:00:02 +0000 UTC
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.