forked from kpango/fastime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.go
86 lines (69 loc) · 1.59 KB
/
global.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package fastime
import (
"context"
"sync"
"time"
)
var (
once sync.Once
instance Fastime
)
func init() {
once.Do(func() {
instance = New().StartTimerD(context.Background(), time.Millisecond*5)
})
}
func IsDaemonRunning() bool {
return instance.IsDaemonRunning()
}
func GetLocation() *time.Location {
return instance.GetLocation()
}
func GetFormat() string {
return instance.GetFormat()
}
// SetLocation replaces time location
func SetLocation(location *time.Location) Fastime {
return instance.SetLocation(location)
}
// SetFormat replaces time format
func SetFormat(format string) Fastime {
return instance.SetFormat(format)
}
// Now returns current time
func Now() time.Time {
return instance.Now()
}
// Since returns the time elapsed since t.
// It is shorthand for fastime.Now().Sub(t).
func Since(t time.Time) time.Duration {
return instance.Since(t)
}
// Stop stops stopping time refresh daemon
func Stop() {
instance.Stop()
}
// UnixNow returns current unix time
func UnixNow() int64 {
return instance.UnixNow()
}
// UnixUNow returns current unix time
func UnixUNow() uint32 {
return instance.UnixUNow()
}
// UnixNanoNow returns current unix nano time
func UnixNanoNow() int64 {
return instance.UnixNanoNow()
}
// UnixUNanoNow returns current unix nano time
func UnixUNanoNow() uint32 {
return instance.UnixUNanoNow()
}
// FormattedNow returns formatted byte time
func FormattedNow() []byte {
return instance.FormattedNow()
}
// StartTimerD provides time refresh daemon
func StartTimerD(ctx context.Context, dur time.Duration) Fastime {
return instance.StartTimerD(ctx, dur)
}