timez

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Day is the duration of one day.
	Day = 24 * time.Hour
	// Week is the duration of one week.
	Week = 7 * Day
)

Variables

This section is empty.

Functions

func DateOf

func DateOf(t time.Time) time.Time

Return the date part of the given time.

func DayEnd

func DayEnd(t time.Time) time.Time

DayEnd gets the end of the day for the given time.

func DayStart

func DayStart(t time.Time) time.Time

DayStart gets the start of the day for the given time.

func LocalDate

func LocalDate(year, month, day int) time.Time

LocalDate gets the local date for the given year, month and day.

func ToJSON

func ToJSON(t time.Time) string

ToJSON gets the time as a JSON string.

func Today

func Today() time.Time

Today gets the current date.

func UTCDate

func UTCDate(year, month, day int) time.Time

UTCDate gets the UTC date for the given year, month and day.

func Yesterday

func Yesterday() time.Time

Yesterday gets the yesterday's date.

func YesterdayNow

func YesterdayNow() time.Time

YesterdayNow gets the yesterday's date.

Types

type Duration

type Duration struct {
	time.Duration
}

Duration is a wrapper for time.Duration with JSON support.

func Dur

func Dur(d time.Duration) Duration

func (Duration) IsZero

func (d Duration) IsZero() bool

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() (b []byte, err error)

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) (err error)

Jump to

Keyboard shortcuts

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