-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_test.go
53 lines (38 loc) · 940 Bytes
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package timejump_test
import (
"fmt"
"time"
"github.com/agatan/timejump"
)
func Example() {
timejump.Activate()
defer timejump.Deactivate()
future := time.Date(1985, 10, 26, 0, 0, 0, 0, time.UTC)
timejump.Stop()
timejump.Jump(future)
fmt.Println(timejump.Now())
// Output:
// 1985-10-26 00:00:00 +0000 UTC
}
func ExampleScale() {
timejump.Activate()
defer timejump.Deactivate()
now := timejump.Now()
// Time passes 100 times faster.
timejump.Scale(1000)
// Sleep just a millisecond.
time.Sleep(time.Millisecond)
sub := timejump.Now().Sub(now)
if sub.Seconds() < 1 {
panic("1 second have passed while sleeping 1 millisecond in this world.")
}
}
func ExampleMove() {
timejump.Activate()
defer timejump.Deactivate()
timejump.Move(time.FixedZone("test/zone", 123))
zone, offset := timejump.Now().Zone()
fmt.Printf("zone: %v, offset: %v\n", zone, offset)
// Output:
// zone: test/zone, offset: 123
}