Documentation ¶
Overview ¶
Package date implements optimized date-parsing routines specific to the date formats that we support.
Currently, only RFC3339Nano dates are supported.
Index ¶
- type Duration
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) After(t2 Time) bool
- func (t Time) AppendRFC3339Nano(b []byte) []byte
- func (t Time) Before(t2 Time) bool
- func (t Time) Day() int
- func (t Time) Equal(t2 Time) bool
- func (t Time) Hour() int
- func (t Time) IsZero() bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) Minute() int
- func (t Time) Month() int
- func (t Time) Nanosecond() int
- func (t Time) Quarter() int
- func (t Time) Round(d time.Duration) Time
- func (t Time) Second() int
- func (t Time) String() string
- func (t Time) Time() time.Time
- func (t Time) Truncate(d time.Duration) Time
- func (t Time) Unix() int64
- func (t Time) UnixMicro() int64
- func (t Time) UnixNano() int64
- func (t *Time) UnmarshalJSON(b []byte) error
- func (t Time) Year() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
type Duration struct {
Year, Month, Day int
}
A Duration represents a calendar duration with year, month, and day components. This is intended to be used to represent expiration times on a granularity of days. Use time.Duration to represent durations smaller than one day.
func ParseDuration ¶
ParseDuration parses a duration string.
func (Duration) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*Duration) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
A Time represents a date and time with a nanosecond component. This representation allows for faster extraction of date components than time.Time, at the cost of slower conversion to Unix times.
This representation cannot store years below 0 or above 16,383. Years falling outside that range will be truncated to fit within that range.
func Date ¶
Date constructs a Time from components. Values of month, day, hour, min, sec, and ns outside their usual ranges will be normalized. Values for year outside of the range [0, 16383] will be truncated to fit within that range.
func Parse ¶
Parse parses a date string from data and returns the associated time and true, or the zero time value and false if the buffer did not contain a recognzied date format.
Parse attempts to recognize strings that (approximately) match RFC3339 timestamps with optional nanosecond precision and timezone/offset components. Parse will automatically ignore leading and trailing whitespace as long as the middle characters of data are unambiguously a timestamp.
func (Time) AppendRFC3339Nano ¶
AppendRFC3339Nano appends t formatted as an RFC3339 compliant string (including nanoseconds) to b. This method is functionally equivalent to:
t.Time().AppendFormat(b, time.RFC3339Nano)
func (Time) IsZero ¶
IsZero returns whether t is the zero value, corresponding to January 1st of year zero.
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Time) Nanosecond ¶
Nanosecond returns the nanosecond component of t.
func (Time) String ¶
String implements io.Stringer. The returned string is meant to be used for debugging purposes.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.