Documentation
¶
Overview ¶
Package timeutil provides time.Now that can be monkey-patched.
Example ¶
package main
import (
"fmt"
"time"
"github.com/google/webpackager/internal/timeutil"
)
func main() {
defer timeutil.ResetNow()
timeutil.StubNowWithFixedTime(time.Date(2020, time.June, 1, 12, 34, 56, 0, time.UTC))
fmt.Println(timeutil.Now())
}
Output: 2020-06-01 12:34:56 +0000 UTC
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Now ¶
Now returns the current local time. It is equal to time.Now by default but can be faked using StubNow or other Stub functions.
func StubNowToAdjust ¶
StubNowToAdjust "adjusts" Now to newNow for testing. The stubbed time continues to advance: Now will return newNow plus the time elapsed since StubNowToAdjust is called.
func StubNowWithFixedTime ¶
StubNowWithFixedTime makes Now return newNow for testing. The stubbed time does not advance.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.