Documentation
¶
Index ¶
Constants ¶
const ISO8601 = "2006-01-02T15:04:05-0700"
Variables ¶
This section is empty.
Functions ¶
func FormatDuration ¶
func ParseDuration ¶
ParseDuration parses a duration string. This works the same as time.ParseDuration except that it supports additional approximated units:
- d: days (defined as 24 hours)
- w: weeks (defined as 7 days)
func ParseExpr ¶
ParseExpr is a convenience interface to ParseExprRef which provides time.Now as the reference time. It's usually the one you want.
func ParseExprRef ¶
ParseExprRef parses a time expression and returns the point in time that it represents. Many expression refer to relative time, which is evaluated relative to the provided reference time.
This function supports a variety of inputs:
The special constants: "today", "yesterday", and "tomorrow", which refers to midnight on those days, relative to the reference time;
The special constant: "now", which refers to the reference time, which is simply returned;
A relative time adjustment, in the form: "(+|-)duration", where "duration" is a duration (as implemented in this package) relative to the reference time. For example, the expression "-10d" refers to the point in time 10 days ago at the same time as this function is invoked;
A date expressed as the day and month, which is assumed to be in the reference year; for example "11-14" refers to midnight on November 14th of the year of the reference time;
A date expressed as the day, month, and year without a time, which refers to midnight on that date.
Any other input, including an empty string is an error.