timex

package
v12.2.0-alpha9 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backwards

func Backwards(typ DateRangeType, end time.Time, n int) []time.Time

Backwards returns a list of dates between "end" and -n (years, months, weeks or days).

func BackwardsN

func BackwardsN(typ DateRangeType, n int) []time.Time

BackwardsN returns the dates from back to "n" years, months, weeks or days from today.

func BackwardsToMonday

func BackwardsToMonday(end time.Time) []time.Time

BackwardsToMonday returns the dates between "end" (including "end") until the previous monday of the current week (including monday).

func Between

func Between(start, end time.Time) []time.Time

Between returns the dates from "start" to "end".

func GetMonthStart

func GetMonthStart(now time.Time) time.Time

GetMonthStart returns the date of the first month day of the current now's month.

func GetWeekDate

func GetWeekDate(now time.Time, weekday, start, end time.Weekday) time.Time

func GetWeekEnd

func GetWeekEnd(now time.Time, endWeekday time.Weekday) time.Time

GetWeekEnd returns the date of the last week day (endWeekday) of the current now's week.

func GetWeekStart

func GetWeekStart(now time.Time, startWeekday time.Weekday) time.Time

GetWeekStart returns the date of the first week day (startWeekday) of the current now's week.

func GetWeekdays

func GetWeekdays(now time.Time, startWeekday, endWeekday time.Weekday) (dates []time.Time)

GetWeekdays returns the range between "startWeekday" and "endWeekday" of the current week.

func GetYearStart

func GetYearStart(now time.Time) time.Time

GetYearStart returns the date of the first year of the current now's year.

func RangeDate

func RangeDate(start, end time.Time) func() time.Time

RangeDate returns a function which returns a time between "start" and "end". When the iteration finishes the returned time is zero.

Types

type DateRangeType

type DateRangeType string
const (
	DayRange   DateRangeType = "day"
	MonthRange DateRangeType = "month"
	WeekRange  DateRangeType = "week"
	YearRange  DateRangeType = "year"
)

Jump to

Keyboard shortcuts

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