date

package
v0.23.5 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RFC1123_1  = "Mon, _2 Jan 2006 15:04:05 MST"
	RFC1123_2  = "Mon, 2 Jan 2006 15:04:05 MST"
	RFC1123Z_1 = "Mon, _2 Jan 2006 15:04:05 -0700"
	RFC1123Z_2 = "Mon, 2 Jan 2006 15:04:05 -0700"

	RFC3339_Local = "2006-01-02T15:04:05Z"
)

Variables

View Source
var (
	ErrInvalidZoneFormat = errors.New("invalid zone format")
)

Functions

func BackDay added in v0.21.0

func BackDay(t time.Time) time.Time

func BackDays added in v0.21.0

func BackDays(t time.Time, days int) time.Time

func BackYear added in v0.21.0

func BackYear(t time.Time) time.Time

func BeforeOrEqual added in v0.23.0

func BeforeOrEqual(t1, t2 time.Time) bool

func DayZero added in v0.21.0

func DayZero() time.Time

func EndOfDay

func EndOfDay(t time.Time) time.Time

func EndOfMonth added in v0.21.0

func EndOfMonth(t time.Time) time.Time

func EndOfPreviousMonth added in v0.21.0

func EndOfPreviousMonth(t time.Time) time.Time

func EndOfPreviousWeek added in v0.21.0

func EndOfPreviousWeek(t time.Time) time.Time

func EndOfPreviousYear added in v0.21.0

func EndOfPreviousYear(t time.Time) time.Time

func EndOfWeek added in v0.21.0

func EndOfWeek(t time.Time) time.Time

func EndOfYear added in v0.21.0

func EndOfYear(t time.Time) time.Time

func EndOfYesterday added in v0.21.0

func EndOfYesterday(t time.Time) time.Time

func FormatJson

func FormatJson(t time.Time) string

func Match

func Match(layout, format string) bool

Format the current time with the given layout and return whether or not it matches the provided format.

func MatchTime

func MatchTime(layout, format string, t time.Time) bool

Format the given time with layout and return whether or not it matches the provided format.

func NextDay added in v0.23.0

func NextDay(t time.Time) time.Time

func NextMonth added in v0.23.0

func NextMonth(t time.Time) time.Time

func ParseDate

func ParseDate(date string) (t time.Time)

Parse a date string to time in format yyyy-mm-dd, yyyy-mm, yyyy.

func ParseRFC1123

func ParseRFC1123(date string) (t time.Time)

Mon, 02 Jan 2006 15:04:05 MST Tue, 07 Dec 2021 19:57:22 -0500 Fri, 6 Nov 2020 19:32:35 +0000

func ParseRFC9557 added in v0.21.0

func ParseRFC9557(value string) (time.Time, error)

1996-12-19T16:39:57-08:00[America/Los_Angeles]

func StartOfDay

func StartOfDay(t time.Time) time.Time

func StartOfMonth added in v0.21.0

func StartOfMonth(t time.Time) time.Time

func StartOfPreviousMonth added in v0.21.0

func StartOfPreviousMonth(t time.Time) time.Time

func StartOfPreviousWeek added in v0.21.0

func StartOfPreviousWeek(t time.Time) time.Time

func StartOfPreviousYear added in v0.21.0

func StartOfPreviousYear(t time.Time) time.Time

func StartOfWeek added in v0.21.0

func StartOfWeek(t time.Time) time.Time

func StartOfYear added in v0.21.0

func StartOfYear(t time.Time) time.Time

func StartOfYesterday added in v0.21.0

func StartOfYesterday(t time.Time) time.Time

func YM1 added in v0.23.0

func YM1(t time.Time) string

func YMD

func YMD(t time.Time) string

Types

type DateRange

type DateRange struct {
	Start time.Time
	End   time.Time
}

func NewDateRange

func NewDateRange(a, b time.Time) DateRange

func NewInterval added in v0.21.2

func NewInterval(t time.Time, name string) DateRange

func (*DateRange) AfterDate

func (d *DateRange) AfterDate() string

func (*DateRange) BeforeDate

func (d *DateRange) BeforeDate() string

func (*DateRange) DayCount added in v0.23.0

func (d *DateRange) DayCount() int

func (*DateRange) IsDay added in v0.23.0

func (d *DateRange) IsDay() bool

func (*DateRange) IsMonth added in v0.23.0

func (d *DateRange) IsMonth() bool

func (*DateRange) IsWeek added in v0.23.0

func (d *DateRange) IsWeek() bool

func (*DateRange) IsYear added in v0.23.0

func (d *DateRange) IsYear() bool

func (*DateRange) IsZero

func (d *DateRange) IsZero() bool

func (*DateRange) MonthCount added in v0.23.0

func (d *DateRange) MonthCount() int

func (*DateRange) PreviousDay added in v0.23.0

func (d *DateRange) PreviousDay() DateRange

func (*DateRange) PreviousMonth added in v0.23.0

func (d *DateRange) PreviousMonth() DateRange

func (*DateRange) PreviousWeek added in v0.23.0

func (d *DateRange) PreviousWeek() DateRange

func (*DateRange) PreviousYear added in v0.23.0

func (d *DateRange) PreviousYear() DateRange

Jump to

Keyboard shortcuts

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