Documentation
¶
Overview ¶
Package timeutil contains some types and functions to help work with times and time spans.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DaysSinceMonday ¶
DaysSinceMonday returns the number of days has passed since last time it was a monday.
This function is a naïve implementation that assumes all weeks have the 7 weekdays. In reality, there are some weird edge cases where some regions have skipped some days, but those cases are left as "undefined behavior".
Types ¶
type TimeSpan ¶
TimeSpan holds a start and end timestamp. Both the start and the end are optional, as represented by being set to nil.
type TimeSpanShorthand ¶
type TimeSpanShorthand byte
TimeSpanShorthand is an enumeration of different TimeSpan templates.
const ( // TimeSpanNone represents a TimeSpan of nil - nil TimeSpanNone TimeSpanShorthand = iota // TimeSpanPast represents a TimeSpan of nil - now TimeSpanPast // TimeSpanFuture represents a TimeSpan of now - nil TimeSpanFuture // TimeSpanThisDay represents a TimeSpan of 00:00 today - 23:59 today TimeSpanThisDay // TimeSpanThisWeek represents a TimeSpan of 00:00 this monday - 23:59 this sunday TimeSpanThisWeek // TimeSpanPrevDay represents a TimeSpan of 00:00 yesterday - 23:59 yesterday TimeSpanPrevDay // TimeSpanPrevWeek represents a TimeSpan of 00:00 monday - 23:59 sunday last week TimeSpanPrevWeek // TimeSpanNextDay represents a TimeSpan of 00:00 tomorrow - 23:59 tomorrow TimeSpanNextDay // TimeSpanNextWeek represents a TimeSpan of 00:00 monday - 23:59 sunday next week TimeSpanNextWeek )
func (TimeSpanShorthand) Span ¶
func (s TimeSpanShorthand) Span(now time.Time) TimeSpan
Span returns a TimeSpan given a specific reference time of when "now" is.
func (TimeSpanShorthand) String ¶
func (s TimeSpanShorthand) String() string