mirror of
https://github.com/la5nta/pat
synced 2026-08-13 17:46:54 -04:00
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.
14 lines
669 B
Go
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")) }
|