2023-08-25 17:36:23 +08:00
|
|
|
package carbon
|
|
|
|
|
|
|
|
// SetTestNow sets a test Carbon instance (real or mock) to be returned when a "now" instance is created.
|
2023-12-27 11:14:52 +08:00
|
|
|
// 设置当前测试时间
|
2023-12-27 18:05:50 +08:00
|
|
|
func (c *Carbon) SetTestNow(carbon Carbon) {
|
2023-12-28 11:29:53 +08:00
|
|
|
c.testNow, c.loc = carbon.TimestampNano(), carbon.loc
|
2023-08-25 17:36:23 +08:00
|
|
|
}
|
|
|
|
|
2023-12-27 11:14:52 +08:00
|
|
|
// UnSetTestNow clears a test Carbon instance (real or mock) to be returned when a "now" instance is created.
|
|
|
|
// 清除当前测试时间
|
2023-12-27 18:05:50 +08:00
|
|
|
func (c *Carbon) UnSetTestNow() {
|
2023-10-16 14:06:45 +08:00
|
|
|
c.testNow = 0
|
2023-08-25 17:36:23 +08:00
|
|
|
}
|
|
|
|
|
2023-12-27 11:14:52 +08:00
|
|
|
// IsSetTestNow report whether there is testing time now.
|
|
|
|
// 是否设置过当前测试时间
|
|
|
|
func (c Carbon) IsSetTestNow() bool {
|
2023-10-16 14:06:45 +08:00
|
|
|
return c.testNow > 0
|
2023-08-25 17:36:23 +08:00
|
|
|
}
|