Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLongDuration ¶
AddLongDuration parses time duration from `duration` argument and adds to time in `now`, returning the resulting time. The duration format is similar to `time` package duration format, with the following changes: - additional duration units are supported:
- 'D' for days,
- 'M' for months,
- 'Y' for years,
- fractional numbers are *not* supported,
- negative numbers are *not* supported,
- whitespace at the beginning and end of duration string is ignored,
- optionally there can be one whitespace character between the number and unit.
Long durations are handled using Time.AddDate function, which works by adding given number of years, months, and days to tval. It normalizes its result, for example, adding one month to October 31 yields December 1, the normalized form for November 31.
Examples:
`AddLongDuration(time.Now(), "1000 Y")` `AddLongDuration(time.Now(), "7 D")` `AddLongDuration(then, "1 M")`
func RelTime ¶
RelTime is a thin wrapper around github.com/dustin/go-humanize in order to provide more accurate data for large durations. Below description is from go-humanize:
RelTime formats a time into a relative string.
It takes two times and two labels. In addition to the generic time delta string (e.g. 5 minutes), the labels are used applied so that the label corresponding to the smaller time is applied.
RelTime(timeInPast, timeInFuture, "earlier", "later") -> "3 weeks earlier"
Types ¶
This section is empty.