aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mastodon/poll.go2
-rw-r--r--renderer/renderer.go12
-rw-r--r--templates/status.tmpl2
3 files changed, 12 insertions, 4 deletions
diff --git a/mastodon/poll.go b/mastodon/poll.go
index 274b95e..cd874a7 100644
--- a/mastodon/poll.go
+++ b/mastodon/poll.go
@@ -10,7 +10,7 @@ import (
type Poll struct {
ID string `json:"id"`
- ExpiresAt time.Time `json:"expires_at"`
+ ExpiresAt *time.Time `json:"expires_at"`
Expired bool `json:"expired"`
Multiple bool `json:"multiple"`
VotesCount int64 `json:"votes_count"`
diff --git a/renderer/renderer.go b/renderer/renderer.go
index 293a6c6..a4f749d 100644
--- a/renderer/renderer.go
+++ b/renderer/renderer.go
@@ -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 {
diff --git a/templates/status.tmpl b/templates/status.tmpl
index c4f2e5f..536f515 100644
--- a/templates/status.tmpl
+++ b/templates/status.tmpl
@@ -126,7 +126,7 @@
<span>{{.Poll.VotesCount}} votes</span>
{{if .Poll.Expired}}
<span> - poll expired </span>
- {{else}}
+ {{else if .Poll.ExpiresAt}}
<span>
- poll ends in
<time datetime="{{FormatTimeRFC3339 .Poll.ExpiresAt}}" title="{{FormatTimeRFC822 .Poll.ExpiresAt}}">