timejuice

package
v1.29.5 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecondsInDay = 86400
)

Variables

This section is empty.

Functions

func GetFirstDayOfMonth added in v1.18.3

func GetFirstDayOfMonth(t time.Time) time.Time

GetFirstDayOfMonth retrieves the first day of the month for the given date, in UTC timezone.

func GetFirstMondayOfYear added in v1.18.3

func GetFirstMondayOfYear(year int) time.Time

GetFirstMondayOfYear retrieves the first Monday of the given year, in UTC timezone.

func GetFirstPeriodStartDate added in v1.18.5

func GetFirstPeriodStartDate(year int) time.Time

GetFirstPeriodStartDate retrieves the date of the first day of the first period of a year.

Result will always be a Sunday, in UTC timezone.

func GetFridayOfGivenPeriod added in v1.18.6

func GetFridayOfGivenPeriod(t time.Time) time.Time

GetFridayOfGivenPeriod retrieves the Friday of the week the given time.Time object is in, in UTC timezone.

func GetLastDayOfLastPeriod added in v1.18.5

func GetLastDayOfLastPeriod(year int) time.Time

GetLastDayOfLastPeriod retrieves the last day of the last period of year, in UTC timezone.

Result will always be a Saturday.

func GetMondayOfGivenPeriod added in v1.18.3

func GetMondayOfGivenPeriod(t time.Time) time.Time

GetMondayOfGivenPeriod retrieves the Monday of the week the given time.Time object is in, in UTC timezone.

func GetPeriodNumber added in v1.18.5

func GetPeriodNumber(t time.Time) int

GetPeriodNumber retrieves the period week number for the given date, from 1 trough 53.

func GetSaturdayOfGivenPeriod added in v1.18.6

func GetSaturdayOfGivenPeriod(t time.Time) time.Time

GetSaturdayOfGivenPeriod retrieves the Saturday of the week the given time.Time object is in, in UTC timezone.

func GetSundayOfGivenPeriod added in v1.18.5

func GetSundayOfGivenPeriod(t time.Time) time.Time

GetSundayOfGivenPeriod retrieves the Sunday of the week the given time.Time object is in, in UTC timezone.

func GetThursdayOfGivenPeriod added in v1.18.6

func GetThursdayOfGivenPeriod(t time.Time) time.Time

GetThursdayOfGivenPeriod retrieves the Thursday of the week the given time.Time object is in, in UTC timezone.

func GetTimeOfWeekday added in v1.18.3

func GetTimeOfWeekday(t time.Time, targetWeekday time.Weekday) time.Time

GetTimeOfWeekday retrieves the time.Time value of the given weekday within the given time.Time object, in UTC timezone.

func GetTuesdayOfGivenPeriod added in v1.18.6

func GetTuesdayOfGivenPeriod(t time.Time) time.Time

GetTuesdayOfGivenPeriod retrieves the Tuesday of the week the given time.Time object is in, in UTC timezone.

func GetWednesdayOfGivenPeriod added in v1.18.6

func GetWednesdayOfGivenPeriod(t time.Time) time.Time

GetWednesdayOfGivenPeriod retrieves the Wednesday of the week the given time.Time object is in, in UTC timezone.

func IsUTCDate

func IsUTCDate(d time.Time) bool

IsUTCDate checks if the given date is in UTC format.

func NowWithPrecision

func NowWithPrecision(precision time.Duration) time.Time

NewWithPrecision returns a new now time.Time (UTC) with the given precision.

func SwapTimezone added in v1.18.0

func SwapTimezone(date time.Time, timezone string, toUTC bool) (time.Time, error)

SwapTimezone takes a date (which can be in any timezone) and returns the date in the specified timezone.

The original timezone is overridden by the new timezone.

This method does not perform any timezone conversion. It simply changes the timezone of the date.

If toUTC is true, the returned date is converted to UTC.

Types

This section is empty.

Jump to

Keyboard shortcuts

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