dateutils

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBusinessDays added in v1.9.0

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

AddBusinessDays adds the specified number of business days to the given time. Business days are Monday through Friday, skipping weekends. Negative values subtract business days.

func AfterOrEqual deprecated added in v1.7.0

func AfterOrEqual(milestone time.Time, date time.Time) bool

AfterOrEqual returns true if date is after or equal to milestone.

Deprecated: Use the standard library comparison helpers directly:

!date.Before(milestone)

func Age added in v1.9.0

func Age(birthdate time.Time) int

Age calculates the age in years from the given birthdate to now.

func AgeAt added in v1.9.0

func AgeAt(birthdate, at time.Time) int

AgeAt calculates the age in years from the given birthdate to the specified date.

func BeforeOrEqual deprecated added in v1.7.0

func BeforeOrEqual(milestone time.Time, date time.Time) bool

BeforeOrEqual returns true if date is before or equal to milestone.

Deprecated: Use the standard library comparison helpers directly:

!date.After(milestone)

func Ceil

func Ceil(t time.Time) time.Time

Ceil - takes a datetime and return a datetime from the same day at 23:59:59 (UTC).

func DaysBetween added in v1.9.0

func DaysBetween(start, end time.Time) int

DaysBetween returns the number of days between two dates. The result is negative if end is before start.

func DaysInMonth added in v1.9.0

func DaysInMonth(t time.Time) int

DaysInMonth returns the number of days in the month of the given time.

func EndOfDay added in v1.9.0

func EndOfDay(t time.Time) time.Time

EndOfDay returns the end of the day (23:59:59.999999999) for the given time in its timezone.

func EndOfWeek added in v1.9.0

func EndOfWeek(t time.Time) time.Time

EndOfWeek returns the end of the week (Saturday at 23:59:59.999999999) for the given time.

func Floor

func Floor(t time.Time) time.Time

Floor - takes a datetime and return a datetime from the same day at 00:00:00 (UTC).

func GetFirstDayOfMonth added in v1.9.0

func GetFirstDayOfMonth() time.Time

GetFirstDayOfMonth returns the first day of the current month at 00:00:00 in the local timezone.

func GetFirstDayOfMonthFor added in v1.9.0

func GetFirstDayOfMonthFor(date time.Time) time.Time

GetFirstDayOfMonthFor returns the first day of the month for the given date at 00:00:00 in the date's timezone.

func GetLastDayOfMonth added in v1.9.0

func GetLastDayOfMonth() time.Time

GetLastDayOfMonth returns the last day of the current month at 23:59:59 in the local timezone.

func GetLastDayOfMonthFor added in v1.9.0

func GetLastDayOfMonthFor(date time.Time) time.Time

GetLastDayOfMonthFor returns the last day of the month for the given date at 23:59:59 in the date's timezone.

func IsSameDay added in v1.9.0

func IsSameDay(a, b time.Time) bool

IsSameDay returns true if both times are on the same day (same year, month, and day).

func IsSameMonth added in v1.9.0

func IsSameMonth(a, b time.Time) bool

IsSameMonth returns true if both times are in the same month (same year and month).

func IsWeekday added in v1.9.0

func IsWeekday(t time.Time) bool

IsWeekday returns true if the given time is on a weekday (Monday through Friday).

func IsWeekend added in v1.9.0

func IsWeekend(t time.Time) bool

IsWeekend returns true if the given time is on a weekend (Saturday or Sunday).

func MustParseDate added in v1.9.0

func MustParseDate(date string) time.Time

MustParseDate parses a date string in RFC3339 format. Panics if parsing fails.

func MustParseDateWithLayout added in v1.9.0

func MustParseDateWithLayout(date string, layout string) time.Time

MustParseDateWithLayout parses a date string using the specified layout. Panics if parsing fails.

func Overlap added in v1.7.2

func Overlap(start1 time.Time, end1 time.Time, start2 time.Time, end2 time.Time) bool

Overlap - returns true if two date intervals overlap.

func ParseDate added in v1.9.0

func ParseDate(date string, fallback time.Time) time.Time

ParseDate parses a date string in RFC3339 format. If parsing fails, returns the fallback value.

func ParseDateWithLayout added in v1.9.0

func ParseDateWithLayout(date string, layout string, fallback time.Time) time.Time

ParseDateWithLayout parses a date string using the specified layout. If parsing fails, returns the fallback value.

func StartOfDay added in v1.9.0

func StartOfDay(t time.Time) time.Time

StartOfDay returns the start of the day (00:00:00) for the given time in its timezone.

func StartOfWeek added in v1.9.0

func StartOfWeek(t time.Time) time.Time

StartOfWeek returns the start of the week (Sunday at 00:00:00) for the given time.

Types

This section is empty.

Jump to

Keyboard shortcuts

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