duration

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SecondsInMinute = 60
	SecondsInHour   = 60 * SecondsInMinute
	SecondsInDay    = 24 * SecondsInHour
	SecondsInMonth  = 30 * SecondsInDay
	SecondsInYear   = 365 * SecondsInDay
)

Variables

View Source
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

func Format

func Format(d time.Duration) string

Format returns a string representation of the duration in the format "XhYmZs".

func New

func New(years, days, hours, minutes, seconds, microseconds int) interval

New creates an interval.

Types

type Days

type Days struct {
	time.Duration
}

func (*Days) MarshalJSON

func (d *Days) MarshalJSON() ([]byte, error)

func (*Days) UnmarshalJSON

func (d *Days) UnmarshalJSON(b []byte) error

type Duration

type Duration time.Duration

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

func (*Duration) Scan

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

Scan implements sql.Scanner.

func (Duration) Value

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

Value implements driver.Valuer.

type Seconds

type Seconds struct {
	time.Duration
}

func (*Seconds) MarshalJSON

func (d *Seconds) MarshalJSON() ([]byte, error)

func (*Seconds) UnmarshalJSON

func (d *Seconds) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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