forked from dromara/carbon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
37 lines (31 loc) · 1.05 KB
/
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
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.time = carbon.time
c.loc = carbon.loc
c.weekStartsAt = carbon.weekStartsAt
c.lang = carbon.lang
c.isTestNow = true
return c
}
// ClearTestNow clears a test Carbon instance (real or mock) to be returned when a "now" instance is created.
func ClearTestNow() Carbon {
return NewCarbon().ClearTestNow()
}
// ClearTestNow clears a test Carbon instance (real or mock) to be returned when a "now" instance is created.
func (c Carbon) ClearTestNow() Carbon {
c.isTestNow = false
return c
}
// HasTestNow reports whether is the test now time.
func HasTestNow() bool {
return NewCarbon().HasTestNow()
}
// HasTestNow reports whether is the test now time.
func (c Carbon) HasTestNow() bool {
return c.isTestNow
}