Documentation ¶
Overview ¶
Package utc is a lightweit time struct stripped of its timezone awareness
Known limitations : dates before the year ~1678 cannot be represented with this time struct, but most of the time we can live with it.
Index ¶
- func FormatDateLong(u UTC, lang lang.Tag) string
- func FormatDateShort(u UTC, lang lang.Tag) string
- func FormatTimeShort(u UTC, lang lang.Tag) string
- type UTC
- func (t UTC) Add(d time.Duration) UTC
- func (t UTC) BeginningOfDay() UTC
- func (t UTC) Ceil(prec time.Duration) UTC
- func (t UTC) Distance(u UTC) time.Duration
- func (t UTC) EndOfDay() UTC
- func (t UTC) Floor(prec time.Duration) UTC
- func (t *UTC) GobDecode(data []byte) error
- func (t UTC) GobEncode() ([]byte, error)
- func (t UTC) IsZero() bool
- func (t UTC) MarshalJSON() ([]byte, error)
- func (t UTC) MarshalText() (text []byte, err error)
- func (t UTC) RFC3339() string
- func (t UTC) RFC3339Nano() string
- func (t UTC) String() string
- func (t UTC) Sub(d time.Duration) UTC
- func (t UTC) Time() time.Time
- func (t *UTC) UnmarshalJSON(data []byte) error
- func (t *UTC) UnmarshalText(text []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type UTC ¶
type UTC int64
UTC is the number of nanoseconds elapsed since January 1, 1970 UTC. The result is undefined if the Unix time in nanoseconds cannot be represented by an int64. Note that this means the result of calling UnixNano on the zero Time is undefined.
func MustParse ¶
MustParse is like Parse, but it panics when there is a parsing error. It simplifies safe initialisation of UTC values.
func Parse ¶
Parse parses a formatted string as defined by the RFC3339 and returns the time value it represents.
Note: If it returns a time.ParseError with "second out of range" when the second is equal to 60, it means it is a leap second. The go time package does not handle leap seconds. More info: https://github.com/golang/go/issues/8728 However, chances are so slim that it does not worth handling that scenario (for now)
func (UTC) BeginningOfDay ¶
BeginningOfDay returns a new UTC with its time reset to midnight
func (UTC) Distance ¶
Distance returns the duration t - u. If the result exceeds the maximum (or minimum) value that can be stored in a Duration, the maximum (or minimum) duration will be returned.
func (UTC) EndOfDay ¶
EndOfDay returns a new UTC with its time set to the last nanosecond of the day
func (UTC) IsZero ¶
IsZero reports whether t represents the zero time instant, January 1, year 1, 00:00:00 UTC.
func (UTC) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. The time is a quoted string in RFC 3339 format, with sub-second precision added if present.
func (UTC) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface It uses the default string representation from String()
func (UTC) RFC3339Nano ¶
RFC3339Nano returns a string representation in RFC3339 format with nanoseconds
func (*UTC) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.
func (*UTC) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface It uses the default layout - RFC3339 with nanoseconds