dates

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As added in v0.2.1

func As(t time.Time, location *time.Location) time.Time

As returns the T as if it was read in the location originally. It is similar to time.In except this function treats the input as zone less. Input of 6pm will become 6pm in the new location.

func EndOfDay

func EndOfDay(t time.Time) time.Time

func EndOfMonth added in v0.2.2

func EndOfMonth(t time.Time) time.Time

func EndOfYear

func EndOfYear(t time.Time) time.Time

func TimeToTime added in v0.3.5

func TimeToTime(t time.Time, duration string, location *time.Location) (time.Time, error)

TimeToTime parses an offset duration string. The calculation is based on an optional anchor (default is the passed in time) plus an offset duration. Valid Anchors:

EOD will calculate the end of day
EOM will calculate the end of month
EOY will calculate end of year

A duration string is a number and unit suffix, such as "300m", "1.5h" or "2h45m". Valid time units are "m", "h". If location is provided, calculations are set to the corresponding time zone. Examples:

"EOD+72h" = end of day in 3 days
"3h" = 3 hours
"EOY" = end of year
"30m" = 30 minutes
"" = now

func ToTime

func ToTime(duration string, location *time.Location) (time.Time, error)

ToTime parses an offset duration string. The calculation is based on an optional anchor (default is NOW) plus an offset duration.

shortcut for TimeToTime(time.Now()).

Types

This section is empty.

Jump to

Keyboard shortcuts

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