timex

package
v0.0.0-...-5b507ad Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 7 Imported by: 9

Documentation

Index

Constants

View Source
const (
	Day time.Duration = 24 * time.Hour
)

Variables

This section is empty.

Functions

func MakeTimeSeries

func MakeTimeSeries(start, stop time.Time, interval time.Duration) []time.Time

Types

type Date

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

func MakeDateSeries

func MakeDateSeries(start, stop Date, intervalDays int) []Date

func NewDateFromTime

func NewDateFromTime(t time.Time) Date

func ParseDate

func ParseDate(s string) (Date, error)

func Today

func Today() Date

func (Date) AddDays

func (d Date) AddDays(n int) Date

func (Date) After

func (d Date) After(d2 Date) bool

func (Date) Before

func (d Date) Before(d2 Date) bool

func (Date) Compare

func (d Date) Compare(d2 Date) int

func (Date) DateValue

func (d Date) DateValue() (pgtype.Date, error)

func (Date) DaysSince

func (d Date) DaysSince(s Date) (days int)

func (Date) In

func (d Date) In(loc *time.Location) time.Time

func (Date) IsZero

func (d Date) IsZero() bool

func (Date) MarshalText

func (d Date) MarshalText() ([]byte, error)

func (*Date) ScanDate

func (d *Date) ScanDate(v pgtype.Date) error

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalText

func (d *Date) UnmarshalText(data []byte) error

func (Date) Weekday

func (d Date) Weekday() time.Weekday

type DateRange

type DateRange struct {
	Start Date
	End   Date
}

func (DateRange) BoundTypes

func (d DateRange) BoundTypes() (lower, upper pgtype.BoundType)

func (DateRange) Bounds

func (d DateRange) Bounds() (lower, upper any)

func (DateRange) IsNull

func (d DateRange) IsNull() bool

func (*DateRange) ScanBounds

func (d *DateRange) ScanBounds() (lowerTarget, upperTarget any)

func (*DateRange) ScanNull

func (d *DateRange) ScanNull() error

func (*DateRange) SetBoundTypes

func (d *DateRange) SetBoundTypes(lower, upper pgtype.BoundType) error

type DaysOfWeek

type DaysOfWeek struct {
	Mo, Tu, We, Th, Fr, Sa, Su bool
}

func ParseDaysOfWeek

func ParseDaysOfWeek(s []bool) (*DaysOfWeek, error)

func (DaysOfWeek) BitsValue

func (src DaysOfWeek) BitsValue() (pgtype.Bits, error)

func (DaysOfWeek) Compare

func (w DaysOfWeek) Compare(w2 DaysOfWeek) int

func (DaysOfWeek) DaysOfWeek

func (w DaysOfWeek) DaysOfWeek() []bool

func (DaysOfWeek) Has

func (w DaysOfWeek) Has(weekday time.Weekday) bool

func (*DaysOfWeek) ScanBits

func (w *DaysOfWeek) ScanBits(bits pgtype.Bits) error

type NullDateRange

type NullDateRange struct {
	DateRange DateRange
	Valid     bool
}

func (NullDateRange) BoundTypes

func (nd NullDateRange) BoundTypes() (lower, upper pgtype.BoundType)

func (NullDateRange) Bounds

func (nd NullDateRange) Bounds() (lower, upper any)

func (NullDateRange) IsNull

func (nd NullDateRange) IsNull() bool

func (*NullDateRange) ScanBounds

func (nd *NullDateRange) ScanBounds() (lowerTarget, upperTarget any)

func (*NullDateRange) ScanNull

func (nd *NullDateRange) ScanNull() error

func (*NullDateRange) SetBoundTypes

func (nd *NullDateRange) SetBoundTypes(lower, upper pgtype.BoundType) error

type NullDaysOfWeek

type NullDaysOfWeek struct {
	DaysOfWeek DaysOfWeek
	Valid      bool
}

func (NullDaysOfWeek) BitsValue

func (nd NullDaysOfWeek) BitsValue() (pgtype.Bits, error)

func (*NullDaysOfWeek) ScanBits

func (nd *NullDaysOfWeek) ScanBits(bits pgtype.Bits) error

type Time

type Time struct {
	Hour   int
	Minute int
	Second int
}

func NewTime

func NewTime(t time.Time) Time

func ParseTime

func ParseTime(s string) (Time, error)

func (Time) After

func (t Time) After(t2 Time) bool

func (Time) Before

func (t Time) Before(t2 Time) bool

func (Time) Compare

func (t Time) Compare(t2 Time) int

func (Time) IsZero

func (t Time) IsZero() bool

func (Time) MarshalText

func (t Time) MarshalText() ([]byte, error)

func (*Time) ScanTime

func (t *Time) ScanTime(v pgtype.Time) error

func (Time) String

func (t Time) String() string

func (Time) TimeValue

func (t Time) TimeValue() (pgtype.Time, error)

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(data []byte) error

Jump to

Keyboard shortcuts

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