forked from golang-module/carbon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
26 lines (22 loc) · 752 Bytes
/
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
package carbon
// SetTestNow sets a test Carbon instance (real or mock) to be returned when a "now" instance is created.
func SetTestNow(carbon Carbon) Carbon {
return NewCarbon().SetTestNow(carbon)
}
// SetTestNow sets a test Carbon instance (real or mock) to be returned when a "now" instance is created.
func (c Carbon) SetTestNow(carbon Carbon) Carbon {
c.testNow = carbon.TimestampNano()
if carbon.loc != nil {
c.loc = carbon.loc
}
return c
}
// ClearTestNow clears a test Carbon instance (real or mock) to be returned when a "now" instance is created.
func (c Carbon) ClearTestNow() Carbon {
c.testNow = 0
return c
}
// HasTestNow report whether there is testing time now.
func (c Carbon) HasTestNow() bool {
return c.testNow > 0
}