Skip to content

Commit ed47d00

Browse files
KN4CK3Rlunny
andauthored
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 <[email protected]>
1 parent 49a4e45 commit ed47d00

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/timeutil/timestamp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ func (ts TimeStamp) FormatDate() string {
103103

104104
// IsZero is zero time
105105
func (ts TimeStamp) IsZero() bool {
106-
return ts.AsTimeInLocation(time.Local).IsZero()
106+
return int64(ts) == 0
107107
}

0 commit comments

Comments
 (0)