datetime

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBusinessDays

func AddBusinessDays(date time.Time, days int) time.Time

AddBusinessDays returns business date in future/past by days.

  • If days is zero, date is returned.
  • If days is negative, date is decremented by days.

func Age

func Age(birthdate time.Time) int

Age returns birthdate years compared to time.Now().

  • If time.Now() is before birthdate, 0 is returned.

func AgeAt

func AgeAt(birthdate, reference time.Time) int

AgeAt returns birthdate years compared to reference.

  • If reference is before birthdate, 0 is returned.

func DaysInMonth

func DaysInMonth(date time.Time) int

DaysInMonth returns number of days in date[month].

func DaysInYear added in v1.0.1

func DaysInYear(date time.Time) int

DaysInYear returns number of days in date[year].

func EndOfDay

func EndOfDay(date time.Time) time.Time

EndOfDay returns end of date[day].

func EndOfMonth

func EndOfMonth(date time.Time) time.Time

EndOfMonth returns end of date[month].

func EndOfWeek

func EndOfWeek(date time.Time) time.Time

EndOfWeek returns end of date[week].

func EndOfYear

func EndOfYear(date time.Time) time.Time

EndOfYear returns end of date[year].

func IsAfter added in v1.0.1

func IsAfter(dateA, dateB time.Time) bool

IsAfter returns true if dateA is after dateB.

func IsAfterOrEqual added in v1.0.1

func IsAfterOrEqual(dateA, dateB time.Time) bool

IsAfterOrEqual returns true if dateA is after or equal dateB.

func IsBefore added in v1.0.1

func IsBefore(dateA, dateB time.Time) bool

IsBefore returns true if dateA is before dateB.

func IsBeforeOrEqual added in v1.0.1

func IsBeforeOrEqual(dateA, dateB time.Time) bool

IsBeforeOrEqual returns true if dateA is before or equal dateB.

func IsBusinessDay

func IsBusinessDay(date time.Time) bool

IsBusinessDay returns true if date is business day.

func IsLeapDay added in v1.0.1

func IsLeapDay(date time.Time) bool

IsLeapDay returns true if date[year,month,day] is leap.

func IsLeapYear

func IsLeapYear(date time.Time) bool

IsLeapYear returns true if date[year] is leap.

func IsSameDay

func IsSameDay(dateA, dateB time.Time) bool

IsSameDay returns true if dateA[year,month,day] is equal dateB[year,month,day].

func IsSameMonth

func IsSameMonth(dateA, dateB time.Time) bool

IsSameMonth returns true if dateA[year,month] is equal dateB[year,month].

func IsSameYear

func IsSameYear(dateA, dateB time.Time) bool

IsSameYear returns true if dateA[year] is equal dateB[year].

func IsWeekend

func IsWeekend(date time.Time) bool

IsWeekend returns true if date is weekend.

func Overlaps

func Overlaps(startA, endA, startB, endB time.Time) bool

Overlaps returns true if range [startA,endA] overlaps with range [startB,endB].

func Parse

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

Parse parses value into time.Time using time.RFC3339.

  • If value is not valid, error is returned.

func ParseWithLayout

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

ParseWithLayout parses value into time.Time using layout.

  • If value is not valid, error is returned.

func StartOfDay

func StartOfDay(date time.Time) time.Time

StartOfDay returns start of date[day].

func StartOfMonth

func StartOfMonth(date time.Time) time.Time

StartOfMonth returns start of date[month].

func StartOfWeek

func StartOfWeek(date time.Time) time.Time

StartOfWeek returns start of date[week].

func StartOfYear

func StartOfYear(date time.Time) time.Time

StartOfYear returns start of date[year].

Types

This section is empty.

Jump to

Keyboard shortcuts

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