From ed47d0062e62ddd23c16687fbd5665a8ffe6912f Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Wed, 26 Oct 2022 15:34:44 +0200 Subject: [PATCH] Fix `Timestamp.IsZero` (#21593) Our implementation of `IsZero` can't work. An "empty" timestamp (= 0) calls `time.Unix(int64(ts), 0).IsZero()` which is always `false`. Only `time.Time{}.IsZero()` is `true`. We call this method ~~only at one place~~ and there the value (`UpdatedUnix`) should be always != 0 so this PR may not have consequences. Co-authored-by: Lunny Xiao --- modules/timeutil/timestamp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/timeutil/timestamp.go b/modules/timeutil/timestamp.go index 40fcb8603f..36b2aff575 100644 --- a/modules/timeutil/timestamp.go +++ b/modules/timeutil/timestamp.go @@ -103,5 +103,5 @@ func (ts TimeStamp) FormatDate() string { // IsZero is zero time func (ts TimeStamp) IsZero() bool { - return ts.AsTimeInLocation(time.Local).IsZero() + return int64(ts) == 0 }