mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2025-05-03 10:28:46 +00:00
Fix time duration value
- Make sure that duration is not < 0 - Handle nil ExpiresAt time in poll
This commit is contained in:
parent
fe31d4197b
commit
dd23ac4867
3 changed files with 12 additions and 4 deletions
|
@ -197,11 +197,19 @@ func DurToStr(dur time.Duration) string {
|
|||
}
|
||||
|
||||
func TimeSince(t time.Time) string {
|
||||
return DurToStr(time.Since(t))
|
||||
d := time.Since(t)
|
||||
if d < 0 {
|
||||
d = 0
|
||||
}
|
||||
return DurToStr(d)
|
||||
}
|
||||
|
||||
func TimeUntil(t time.Time) string {
|
||||
return DurToStr(time.Until(t))
|
||||
d := time.Until(t)
|
||||
if d < 0 {
|
||||
d = 0
|
||||
}
|
||||
return DurToStr(d)
|
||||
}
|
||||
|
||||
func FormatTimeRFC3339(t time.Time) string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue