Documentation ¶
Overview ¶
time2 is a collection of functions meant to supplement the capabilities provided by the standard "time" package.
Index ¶
- Variables
- func NowFloat() float64
- func TimeToFloat(t time.Time) float64
- type Clock
- type MockClock
- func (c *MockClock) Advance(delta time.Duration)
- func (c *MockClock) AdvanceTo(t time.Time)
- func (c *MockClock) AdvanceToNextWakeup()
- func (c *MockClock) After(d time.Duration) <-chan time.Time
- func (c *MockClock) NextWakeupTime() time.Time
- func (c *MockClock) Now() time.Time
- func (c *MockClock) NowFloat() float64
- func (c *MockClock) Set(t time.Time)
- func (c *MockClock) SetLogf(f func(format string, args ...interface{}))
- func (c *MockClock) Since(t time.Time) time.Duration
- func (c *MockClock) Sleep(d time.Duration)
- func (c *MockClock) WakeupsCount() int
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultClock = &realClock{}
Functions ¶
func TimeToFloat ¶
Convert Time to epoch seconds with subsecond precision.
Types ¶
type Clock ¶
type Clock interface { Now() time.Time Since(t time.Time) time.Duration After(d time.Duration) <-chan time.Time Sleep(d time.Duration) }
These methods are all equivalent to those provided by the time package
type MockClock ¶
type MockClock struct {
// contains filtered or unexported fields
}
A fake clock useful for testing timing.
func NewMockClock ¶
func (*MockClock) AdvanceToNextWakeup ¶
func (c *MockClock) AdvanceToNextWakeup()
func (*MockClock) NextWakeupTime ¶
func (*MockClock) Set ¶
Set the mock clock to a specific time. NOTE: scheduled wakeup calls are not modified when resetting the clock to an earlier time; for example, suppose the current time is X, and there is a pending wakeup call at time X+1. If we reset the clock to X-2, the wakeup time will still be at X+1.
func (*MockClock) WakeupsCount ¶
Click to show internal directories.
Click to hide internal directories.