mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-24 02:36:10 +01:00
- Backport of #22171 - Currently, the 'IsZero' function for 'TimeStamp' just checks if the unix time is zero, which is not the behavior of 'Time.IsZero()', but Gitea is using this method in accordance with the behavior of 'Time.IsZero()'. - Adds a new condition to check for the zero time instant. - Fixes a bug where non-expiring GPG keys where shown as they expired on Jan 01, 0001. - Related https://codeberg.org/Codeberg/Community/issues/791
This commit is contained in:
parent
068e96fbd2
commit
f51a19c537
|
@ -13,8 +13,13 @@ import (
|
||||||
// TimeStamp defines a timestamp
|
// TimeStamp defines a timestamp
|
||||||
type TimeStamp int64
|
type TimeStamp int64
|
||||||
|
|
||||||
// mock is NOT concurrency-safe!!
|
var (
|
||||||
var mock time.Time
|
// mock is NOT concurrency-safe!!
|
||||||
|
mock time.Time
|
||||||
|
|
||||||
|
// Used for IsZero, to check if timestamp is the zero time instant.
|
||||||
|
timeZeroUnix = time.Time{}.Unix()
|
||||||
|
)
|
||||||
|
|
||||||
// Set sets the time to a mocked time.Time
|
// Set sets the time to a mocked time.Time
|
||||||
func Set(now time.Time) {
|
func Set(now time.Time) {
|
||||||
|
@ -103,5 +108,5 @@ func (ts TimeStamp) FormatDate() string {
|
||||||
|
|
||||||
// IsZero is zero time
|
// IsZero is zero time
|
||||||
func (ts TimeStamp) IsZero() bool {
|
func (ts TimeStamp) IsZero() bool {
|
||||||
return int64(ts) == 0
|
return int64(ts) == 0 || int64(ts) == timeZeroUnix
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue