Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertToTime(timeString string) (t time.Time, err error)
- func GetMonthRange(ref time.Time) (first, last time.Time)
- func GetWeekRange(ref time.Time) (first, last time.Time)
- func Now() time.Time
- func Today() time.Time
- func TruncateDate(t time.Time) time.Time
- func TruncateDateWithTimezone(t time.Time, l *time.Location) time.Time
Constants ¶
const ( FullTimeFormat = "2006-01-02 15:04:05" SimplerTimeFormat = "2006-01-02 15:04" OnlyTimeFormat = "15:04:05" SimplerOnlyTimeFormat = "15:04" SimplerOnlyTimeFormatWL = "5:04" NowTimeFormat = "now" SimplestOnlyTimeFormat = "1504" SimplestOnlyTimeFormatWL = "504" )
Variables ¶
var ErrInvalidReliveTime = errors.New(
"supported relative time formats are: " +
"+15:04:05, +15:04 or unit descriptive +1d15h4m5s, " +
"+15h5s, 120m",
)
Functions ¶
func ConvertToTime ¶
ConvertToTime will try to convert a string do time.Time looking for the format that best fits it and assuming "today" when necessary. If the string starts with `yesterday`, than it will be exchanged for a date-string with the format: 2006-01-02 If the string starts with `+` or `-` than the string will be treated as "relative time expressions", and will be calculated as the diff from now and it. If the string is "now" than `time.Now()` in the local timezone will be returned.
func GetMonthRange ¶
GetMonthRange given a time it returns the first and last date of a month
func GetWeekRange ¶
GetWeekRange given a time it returns the first and last date of a week
func Today ¶
Today will return a UTC time.Time for the same day as time.Now() in Local time, but at 0:00:00.000
func TruncateDate ¶
TruncateDate clears the hours, minutes and seconds of a time.Time for UTC
Types ¶
This section is empty.