Documentation
¶
Overview ¶
Package pgdatetime supports the parsing and displaying of PostgreSQL style datetimes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Component ¶
type Component uint64
Component is a component of date or time.
const ( ComponentNumber Component = 1 << iota ComponentString ComponentDate ComponentTime ComponentTZ ComponentAgo ComponentSpecial ComponentEarly ComponentLate ComponentEpoch ComponentNow ComponentYesterday ComponentToday ComponentTomorrow ComponentZulu ComponentDelta ComponentSecond ComponentMinute ComponentHour ComponentDay ComponentWeek ComponentMonth ComponentQuarter ComponentYear ComponentDecade ComponentCentury ComponentMillennium ComponentMillis ComponentMicros ComponentJulian ComponentDOW ComponentDOY ComponentTZHour ComponentTZMinute ComponentISOYear ComponentISODOW ComponentTimeMask = (ComponentHour | ComponentMinute | ComponentSecond) ComponentDateMask = (ComponentDay | ComponentMonth | ComponentYear) )
type DateStyle ¶
type DateStyle struct { Order Order Style Style // FixedZonePrefix is set if we should ignore printing out the shorthand // timezone if it begins with this prefix. // Leave blank to always output timezone name. FixedZonePrefix string }
DateStyle refers to the output style supported by PostgreSQL. See also: https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT
func DefaultDateStyle ¶
func DefaultDateStyle() DateStyle
DefaultDateStyle returns the default datestyle for Postgres.
func ParseDateStyle ¶
ParseDateStyle parses a given DateStyle.
type ParseError ¶
ParseError is an error that appears during parsing.
func NewParseError ¶
func NewParseError(idx int, description string) *ParseError
NewParseError returns a ParseError with the given fields.
func NewParseErrorf ¶
func NewParseErrorf(idx int, descriptionf string, args ...interface{}) *ParseError
NewParseErrorf returns a ParseError with the given fields.
func (*ParseError) Error ¶
func (pe *ParseError) Error() string
Error implements the error interface.
type ParseResult ¶
type ParseResult struct { Type ParseResultType Time time.Time }
ParseResult returns the result of parsing a time.
func ParseTimestampTZ ¶
ParseTimestampTZ parses a TimestampTZ element.
type ParseResultType ¶
type ParseResultType int
ParseResultType is the type of result time returns.
const ( // ParseResultTypeAbsoluteTime signifies an absolute return type of time. ParseResultTypeAbsoluteTime ParseResultType = iota // ParseResultTypeRelativeTime signifies time was parsed to a relative // to a given point in time, e.g. yesterday, today, tomorrow. ParseResultTypeRelativeTime // ParseResultTypePosInfinity signifies time is +Infinity. ParseResultTypePosInfinity // ParseResultTypeNegInfinity signifies time is -Infinity. ParseResultTypeNegInfinity )
func (ParseResultType) String ¶
func (i ParseResultType) String() string