timejuice

package
v1.18.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Description: Time related helper functions to manage timezones, weekdays, and payroll weeks.

Index

Constants

This section is empty.

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.

func GetFirstMondayOfYear added in v1.18.3

func GetFirstMondayOfYear(ctx context.Context, year int) time.Time

GetFirstMondayOfYear retrieves the first Monday of the given year.

func GetLastSundayOfPayPeriods added in v1.18.3

func GetLastSundayOfPayPeriods(ctx context.Context, year int) time.Time

GetLastSundayOfPayPeriods retrieves the last Sunday before the first Monday of the given year.

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.

func GetNextSundayOfGivenPeriod added in v1.18.3

func GetNextSundayOfGivenPeriod(t time.Time) time.Time

GetNextSundayOfGivenPeriod retrieves the next Sunday after the given time.Time object.

func GetPayrollWeekNumber added in v1.18.3

func GetPayrollWeekNumber(ctx context.Context, t time.Time) int

GetPayrollWeekNumber retrieves the payroll week number for the given date, from 1 trough 53, where the first payroll week is the first Monday of the year.

func GetTimeOfWeekday added in v1.18.3

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

GetTimeOfWeekday retrieves the time of the given weekday within the given time.Time object.

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