pqinterval

package
v2.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooBig = errors.New("interval overflows time.Duration")

ErrTooBig - returned by Interval.Duration and Duration.Scan if the interval would overflow a time.Duration.

Functions

This section is empty.

Types

type Interval

type Interval struct {

	/**
	Value is not null
	*/
	Valid bool
	// contains filtered or unexported fields
}

Interval can represent the full range of PostgreSQL's interval type.

func New

func New(years, days, hours, minutes, seconds, microseconds int64) Interval

New creates an Interval.

func (Interval) Duration

func (ival Interval) Duration() (time.Duration, error)

Duration - converts an Interval into a time.Duration with the same semantics as `EXTRACT(EPOCH from <interval>)` in PostgreSQL.

func (Interval) Hours

func (ival Interval) Hours() int32

Hours returns the number of hours in the interval.

func (Interval) Microseconds

func (ival Interval) Microseconds() int64

Microseconds returns the number of microseconds in the interval, up to the number of microseconds in an hour.

func (*Interval) Scan

func (ival *Interval) Scan(src interface{}) error

Scan implements sql.Scanner.

func (Interval) Value

func (ival Interval) Value() (driver.Value, error)

Value implements driver.Valuer.

func (Interval) Years

func (ival Interval) Years() int32

Years returns the number of years in the interval.

type NullDuration

type NullDuration struct {
	Duration time.Duration
	Valid    bool
}

NullDuration - Duration is a time.Duration alias that supports the driver.Valuer and sql.Scanner interfaces.

func (*NullDuration) Scan

func (d *NullDuration) Scan(src interface{}) error

Scan implements sql.Scanner.

func (NullDuration) Value

func (d NullDuration) Value() (driver.Value, error)

Value implements driver.Valuer.

type ParseErr

type ParseErr struct {
	String string
	Cause  error
}

ParseErr is returned on a failure to parse a postgres result into an Interval or Duration.

func (ParseErr) Error

func (pe ParseErr) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL