diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-10-26 15:34:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-26 21:34:44 +0800 |
commit | ed47d0062e62ddd23c16687fbd5665a8ffe6912f (patch) | |
tree | af5c5e0ccc7d7b3d949a007120447f58c162e484 /modules/timeutil | |
parent | 49a4e4555a8af51f5a83ee321607c328930c070e (diff) | |
download | gitea-ed47d0062e62ddd23c16687fbd5665a8ffe6912f.tar.gz gitea-ed47d0062e62ddd23c16687fbd5665a8ffe6912f.zip |
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 <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/timeutil')
-rw-r--r-- | modules/timeutil/timestamp.go | 2 |
1 files changed, 1 insertions, 1 deletions
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 } |