From adbf576a6e08e36a44e5092ab966e82dab1d1972 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Wed, 2 May 2018 10:23:07 +0300 Subject: [PATCH] fix gpg expired bug when time is zero (#3584) (#3884) --- modules/util/time_stamp.go | 5 +++++ templates/user/settings/keys_gpg.tmpl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/util/time_stamp.go b/modules/util/time_stamp.go index a03560b24..56f41882f 100644 --- a/modules/util/time_stamp.go +++ b/modules/util/time_stamp.go @@ -59,3 +59,8 @@ func (ts TimeStamp) FormatLong() string { func (ts TimeStamp) FormatShort() string { return ts.Format("Jan 02, 2006") } + +// IsZero is zero time +func (ts TimeStamp) IsZero() bool { + return ts.AsTime().IsZero() +} diff --git a/templates/user/settings/keys_gpg.tmpl b/templates/user/settings/keys_gpg.tmpl index ac3fc3ee6..c2af8554c 100644 --- a/templates/user/settings/keys_gpg.tmpl +++ b/templates/user/settings/keys_gpg.tmpl @@ -26,7 +26,7 @@
{{$.i18n.Tr "settings.add_on"}} {{.AddedUnix.FormatShort}} - - {{if .ExpiredUnix}}{{$.i18n.Tr "settings.valid_until"}} {{.ExpiredUnix.FormatShort}}{{else}}{{$.i18n.Tr "settings.valid_forever"}}{{end}} + {{if not .ExpiredUnix.IsZero}}{{$.i18n.Tr "settings.valid_until"}} {{.ExpiredUnix.FormatShort}}{{else}}{{$.i18n.Tr "settings.valid_forever"}}{{end}}