bsr,
Usually, all times should at least be stored as a UTC time, some dates
should also be stored as a local time.
If I am a bank and all transactions accepted by 3 p.m. local time
(standard or daylight savings time depending on the time of year) are
posted that day, the UTC time does not tell me what day I should post
the transaction, the local time does. Also, a local timestamp is often
useful as an audit trail. For example, a bank teller or ATM
transaction should have both a UTC and a local timestamp.
UTC time provides a unique (ignoring leap seconds) set of ordered
values across all time zones.
For a complete UTC time, time.Parse or set the Year, Month, Day, Hour,
Minute, and Second time.Time values. ZoneOffset should be zero for UTC
time.
Local time is represented as numeric zone offset (in minutes) from a
UTC time.
For a complete local time, time.Parse or set the Year, Month, Day,
Hour, Minute, Second, and ZoneOffset time.Time values.
Any time.Time missing values are set to zero values for the type (for
Weekday that's Sunday). ZoneOffset is zero for UTC time. Weekday can
be computed from Year, Month, and Day time.Time values by converting
to seconds and back. Full and abbreviated time.Time.Zone strings are
not well-defined.
Time zone abbreviations are relative to a geographic location and
date. If my time zone abbreviation is EST, am I in Sydney, Australia
or New York City, USA? If live in Pulaski County, Indiana, USA, what
was my time zone abbreviation in 2006 and what is it now? Time zone
strings and abbreviations are not portable across time zone databases.
For example, compare Linux (tzdata) and Windows (registry).
As seasonal time zones change, absent the zone offset a local time is
not unique, when clocks are turned back local timestamps repeat. In
Samoa, the local time dates are not unique as they switch to and fro
across the International Date Line.
When time.Time t is converted by t.Seconds(), the number of seconds is
adjusted by the value of Time.ZoneOffset minutes.
For standard parse and format layouts, use the layout name. For
example, s := t.Format(time.RFC3339).
You can provide a custom format layout in the same way that you
provide a custom parse layout. For example, s :=
t.Format("2006-01-02") for just the date.
Peter