Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RealClock = &systemClock{}
View Source
var RealUTCClock = &systemUTCClock{}
Functions ¶
func MulDur ¶ added in v0.1.1
MulDur multiplies duration by a float value.
Example ¶
package main
import (
"time"
"github.com/cristalhq/timex"
)
func main() {
window := time.Minute
window = timex.MulDur(window, 1.5)
if window.Seconds() != 90 {
panic("want 90 have " + window.String())
}
window = time.Minute
window = time.Duration(float64(window) * 1.5)
if window.Seconds() != 90 {
panic("want 90 have " + window.String())
}
}
Output:
Types ¶
type ManualClock ¶
type ManualClock struct {
// contains filtered or unexported fields
}
ManualClock represents clock than can be controlled manually.
func NewManualClock ¶
func NewManualClock(curr time.Time) *ManualClock
NewManualClock returns manual Clock with a given time.
func (*ManualClock) Add ¶
func (c *ManualClock) Add(d time.Duration)
func (*ManualClock) Now ¶
func (c *ManualClock) Now() time.Time
func (*ManualClock) Set ¶
func (c *ManualClock) Set(t time.Time)
type Timestamp ¶ added in v0.1.1
func AsTimestamp ¶ added in v0.1.1
AsTimestamp returns time.Time wrapped as Timestamp.
func TimestampFromMilli ¶ added in v0.1.2
TimestampFromMilli returns Timestamp from the Unix time in milliseconds.
func TimestampFromString ¶ added in v0.1.2
TimestampFromString returns Timestamp fomr the string representing Unix time.
func (Timestamp) MarshalJSON ¶ added in v0.1.1
MarshalJSON implements json.Marshaler interface.
func (*Timestamp) UnmarshalJSON ¶ added in v0.1.1
UnmarshalJSON implements json.Unmarshaler interface.
Click to show internal directories.
Click to hide internal directories.