Skip to content

Commit

Permalink
Fix Timestamp.IsZero (go-gitea#21593)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
KN4CK3R and lunny committed Oct 26, 2022
1 parent 3f7cab4 commit 7618631
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/timeutil/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 7618631

Please sign in to comment.