Documentation ¶
Overview ¶
Package datetime provides a ParseTime function for turning commonly-used ISO 8601 date/time formats into Golang time.Time variables.
Unlike Go's built-in RFC-3339 time format, this package automatically supports ISO 8601 date and time stamps with varying levels of granularity. Examples:
Index ¶
Constants ¶
const ( ILLEGAL token = iota EOF NUMBER DASH COLON DOT PLUS T Z )
Parsing tokens for internal use, only capitalized for stylistic reasons.
Variables ¶
This section is empty.
Functions ¶
func JSONParse ¶
JSONParse will take a JSON bytes value with quotes around it, and parse it into a time.Time.
func Parse ¶
Parse takes a string with a ISO 8601 timestamp in it, and a default location to use for timestamps that don't include one, and returns a time.Time.
func ParseLocal ¶
ParseLocal takes a string with a ISO 8601 timestamp in it and returns a time.Time. For inputs that do not specify a location, time.Local will be used.
Types ¶
type DefaultLocal ¶
DefaultLocal is just like a time.Time but serializes as an RFC3339Nano format when stringified or marshaled to JSON. When parsed/unmarshaled, it uses time.Local as the location for timestamps that don't specify one.
func (*DefaultLocal) Scan ¶
func (d *DefaultLocal) Scan(value interface{}) error
Scan implements the sql Scanner interface, allowing datetime.DefaultLocal fields to be read from database columns.
func (DefaultLocal) String ¶
func (d DefaultLocal) String() string
String returns the DefaultLocal's RFC3339Nano representation.
func (*DefaultLocal) UnmarshalJSON ¶
func (d *DefaultLocal) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the JSON Unmarshaler interface, allowing datetime.DefaultLocal struct fields to be read from JSON string fields.
type DefaultUTC ¶
DefaultUTC is just like a time.Time but serializes as an RFC3339Nano format when stringified or marshaled to JSON. When parsed/unmarshaled, it uses time.UTC as the location for timestamps that don't specify one.
func (*DefaultUTC) Scan ¶
func (d *DefaultUTC) Scan(value interface{}) error
Scan implements the sql Scanner interface, allowing datetime.DefaultUTC fields to be read from database columns.
func (DefaultUTC) String ¶
func (d DefaultUTC) String() string
String returns the DefaultUTC's RFC3339Nano representation.
func (*DefaultUTC) UnmarshalJSON ¶
func (d *DefaultUTC) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the JSON Unmarshaler interface, allowing datetime.DefaultUTC struct fields to be read from JSON string fields.