pat/internal/forms/date.go
Martin Hebnes Pedersen 0f183d03d6 Fix incorrect time layout strings for UTC variants
The reference date is MST (seven hours west of GMT). This is a very
common mistake when constructing formatting strings to be used with
time.Format.

Since we converted all dates that includes zone information to UTC
*before* outputting in Z time, this bug did not affect the output
strings. But it's best to use the correct reference time anyway, in case
we later add a string representation including zone information that is
not UTC.
2023-10-16 13:55:02 +00:00

14 lines
669 B
Go

package forms
import (
"strings"
"time"
)
func formatDateTime(t time.Time) string { return t.Format("2006-01-02 15:04:05") }
func formatDateTimeUTC(t time.Time) string { return t.UTC().Format("2006-01-02 15:04:05Z07:00") }
func formatDate(t time.Time) string { return t.Format("2006-01-02") }
func formatTime(t time.Time) string { return t.Format("15:04:05") }
func formatDateUTC(t time.Time) string { return t.UTC().Format("2006-01-02Z07:00") }
func formatTimeUTC(t time.Time) string { return t.UTC().Format("15:04:05Z07:00") }
func formatUDTG(t time.Time) string { return strings.ToUpper(t.UTC().Format("021504Z07:00 Jan 2006")) }