Skip to content

Commit cde0268

Browse files
KN4CK3Rlunny
andcommitted
Fix Timestamp.IsZero (go-gitea#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 <xiaolunwen@gmail.com>
1 parent 291787a commit cde0268

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/timeutil/timestamp.go

Lines changed: 1 addition & 1 deletion
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)