Skip to content

Commit

Permalink
Show expiration time in server's local time
Browse files Browse the repository at this point in the history
The server is currently showing the expiration time in UTC time zone. For users in time zones behind UTC, this causes the expiration date to display a day behind.

The server's local time is probably going to be closer to the client's time zone, so this change uses the server's time zone to display expiration time on the file info page.
  • Loading branch information
mtlynch committed Jan 4, 2025
1 parent 8168834 commit 55e8813
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions handlers/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,10 @@ func (s Server) fileInfoGet() http.HandlerFunc {
if et == picoshare.NeverExpire {
return "Never"
}
t := time.Time(et)
t := et.Time().Local()
delta := t.Sub(s.clock.Now())
return fmt.Sprintf("%s (%.0f days)", t.Format(time.DateOnly), delta.Hours()/24)
daysRemaining := delta.Hours() / 24
return fmt.Sprintf("%s (%.0f days)", t.Format(time.DateOnly), daysRemaining)
},
"formatTimestamp": func(t time.Time) string {
return t.Format(time.RFC3339)
Expand Down

0 comments on commit 55e8813

Please sign in to comment.