We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
TimeStamp.IsZero()
1 parent 2774671 commit 40ba750Copy full SHA for 40ba750
modules/timeutil/timestamp.go
@@ -12,8 +12,13 @@ import (
12
// TimeStamp defines a timestamp
13
type TimeStamp int64
14
15
-// mock is NOT concurrency-safe!!
16
-var mock time.Time
+var (
+ // mock is NOT concurrency-safe!!
17
+ mock time.Time
18
+
19
+ // Used for IsZero, to check if timestamp is the zero time instant.
20
+ timeZeroUnix = time.Time{}.Unix()
21
+)
22
23
// Set sets the time to a mocked time.Time
24
func Set(now time.Time) {
@@ -102,5 +107,5 @@ func (ts TimeStamp) FormatDate() string {
102
107
103
108
// IsZero is zero time
104
109
func (ts TimeStamp) IsZero() bool {
105
- return int64(ts) == 0
110
+ return int64(ts) == 0 || int64(ts) == timeZeroUnix
106
111
}
0 commit comments