Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"time"
"github.com/rakunlabs/tummy"
)
func main() {
tummy.Enable()
defer tummy.Disable()
tummy.Resume() // it is already resuming
tummy.SetTime(time.Date(1919, 5, 19, 12, 0, 0, 0, time.UTC))
tummy.AddDuration(2 * time.Hour)
fmt.Println(tummy.Now().Hour()) // 14
tummy.AddDate(0, 0, 1)
fmt.Println(tummy.Now().Day()) // 20
tummy.Pause()
tummy.SetTime(time.Date(1923, 10, 23, 12, 0, 0, 0, time.UTC))
fmt.Println(tummy.Now().Format(time.RFC3339Nano) == "1923-10-23T12:00:00Z") // true
tummy.Pause()
fmt.Println(tummy.IsPaused()) // true
tummy.Resume()
tummy.Disable() // reset tummy.Now to time.Now
before := time.Now()
now := tummy.Now()
after := time.Now()
fmt.Println(!now.Before(before) && !now.After(after)) // true
}
Output: 14 20 true true true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Now = time.Now
)
Functions ¶
func AddDuration ¶
AddDuration adds a duration to the global tummy.Now.
func Disable ¶
func Disable()
Disable resets the global tummy.Now to the original time.Now function.
func IsPaused ¶ added in v0.1.1
func IsPaused() bool
IsPaused checks if the global tummy.Now is currently paused.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.