summaryrefslogtreecommitdiffstats
path: root/modules/timeutil
diff options
context:
space:
mode:
Diffstat (limited to 'modules/timeutil')
-rw-r--r--modules/timeutil/timestamp.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/timeutil/timestamp.go b/modules/timeutil/timestamp.go
index 4618db9a76..c8e0d4bdc1 100644
--- a/modules/timeutil/timestamp.go
+++ b/modules/timeutil/timestamp.go
@@ -12,8 +12,13 @@ import (
// TimeStamp defines a timestamp
type TimeStamp int64
-// mock is NOT concurrency-safe!!
-var mock time.Time
+var (
+ // mock is NOT concurrency-safe!!
+ mock time.Time
+
+ // Used for IsZero, to check if timestamp is the zero time instant.
+ timeZeroUnix = time.Time{}.Unix()
+)
// Set sets the time to a mocked time.Time
func Set(now time.Time) {
@@ -102,5 +107,5 @@ func (ts TimeStamp) FormatDate() string {
// IsZero is zero time
func (ts TimeStamp) IsZero() bool {
- return int64(ts) == 0
+ return int64(ts) == 0 || int64(ts) == timeZeroUnix
}