time

package
v0.1.0-rc8 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RFC3339Day   = "2006-01-02"
	RFC3339Month = "2006-01"
	RFC3339Year  = "2006"
)
View Source
const (
	Day  = 24 * time.Hour
	Week = 7 * Day
)

Variables

This section is empty.

Functions

func AfterOrEqual

func AfterOrEqual(t, u time.Time) bool

func BeforeOrEqual

func BeforeOrEqual(t, u time.Time) bool

func Between

func Between(from, to, u time.Time) bool

Between returns true if min <= u, u <= max. If you want to exclude some border, please use built-in Before or After methods:

  • [from, to]: Between(u, from, to)
  • (from, to): from.Before(u) && to.After(u)
  • [from, to): BeforeOrEqual(from, u) && to.After(u)
  • (from, to]: from.Before(u) && AfterOrEqual(to, u)

func CopyClock

func CopyClock(from, to time.Time) time.Time

func Now

func Now() time.Time

func Parse

func Parse(layout, value string) (time.Time, error)

func TruncateToDay

func TruncateToDay(t time.Time) time.Time

func TruncateToMonth

func TruncateToMonth(t time.Time) time.Time

func TruncateToWeek

func TruncateToWeek(t time.Time) time.Time

func TruncateToYear

func TruncateToYear(t time.Time) time.Time

Types

type Range

type Range struct {
	// contains filtered or unexported fields
}

func NewRange

func NewRange(from time.Time, to time.Time) Range

func RangeByMonths

func RangeByMonths(t time.Time, months int, half bool) Range

func RangeByWeeks

func RangeByWeeks(t time.Time, weeks int, half bool) Range

func RangeByYears

func RangeByYears(t time.Time, years int, half bool) Range

func (Range) Contains

func (r Range) Contains(t time.Time) bool

func (Range) ExcludeFuture

func (r Range) ExcludeFuture() Range

func (Range) From

func (r Range) From() time.Time

func (Range) IsZero

func (r Range) IsZero() bool

func (Range) Shift

func (r Range) Shift(shift time.Duration) Range

func (Range) To

func (r Range) To() time.Time

func (Range) TrimByYear

func (r Range) TrimByYear(year int) Range

type Time

type Time = time.Time

type Weekday

type Weekday = time.Weekday
const (
	Sunday Weekday = iota
	Monday
	Tuesday
	Wednesday
	Thursday
	Friday
	Saturday
)

Jump to

Keyboard shortcuts

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