Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTooBig = errors.New("interval overflows time.Duration")
ErrTooBig is returned by Interval.Duration and Duration.Scan if the interval would overflow a time.Duration.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
Duration is a time.Duration alias that supports the following additional interfaces: - driver.Valuer - sql.Scanner - json.Marshaler - json.Unmarshaler
func (Duration) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler. IMPORTANT NOTE: We are serializing Duration as an *integer* number of milliseconds. For our use case, this is sufficient: we don't need any more precision than millisecond.
func (Duration) Milliseconds ¶ added in v0.3.0
func (*Duration) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler
type Interval ¶
type Interval struct {
// contains filtered or unexported fields
}
Interval can represent the full range of PostgreSQL's interval type.
func (Interval) Duration ¶
Duration converts an Interval into a time.Duration with the same semantics as `EXTRACT(EPOCH from <interval>)` in PostgreSQL.
func (Interval) Microseconds ¶
Microseconds returns the number of microseconds in the interval, up to the number of microseconds in an hour.
type NullDuration ¶
func NewNullDuration ¶ added in v0.3.2
func NewNullDuration(d Duration, valid bool) NullDuration
func (NullDuration) MarshalJSON ¶ added in v0.3.1
func (nd NullDuration) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler. IMPORTANT NOTE: We are serializing NullDuration as an *integer* number of milliseconds. For our use case, this is sufficient: we don't need any more precision than millisecond.
func (NullDuration) Milliseconds ¶ added in v0.3.2
func (nd NullDuration) Milliseconds() float64
Milliseconds returns the number of milliseconds in the duration
func (*NullDuration) Scan ¶
func (nd *NullDuration) Scan(src interface{}) error
func (*NullDuration) UnmarshalJSON ¶ added in v0.3.1
func (nd *NullDuration) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler
type NullInterval ¶
func (*NullInterval) Scan ¶
func (nival *NullInterval) Scan(src interface{}) error