Documentation ¶
Index ¶
- func AddClock(t time.Time, c Clock) time.Time
- func HoursBetween(a, b time.Time) int
- func NextWeekday(t time.Time, w time.Weekday) time.Time
- func PrevWeekday(t time.Time, w time.Weekday) time.Time
- func StartOfDay(t time.Time) time.Time
- type Clock
- func (c Clock) Days() (int, Clock)
- func (c Clock) FirstOfDay(t time.Time) time.Time
- func (c Clock) Format(layout string) string
- func (c Clock) Hour() int
- func (c Clock) Is(t time.Time) bool
- func (c Clock) LastOfDay(t time.Time) time.Time
- func (c Clock) Minute() int
- func (c *Clock) Scan(value interface{}) error
- func (c Clock) String() string
- func (c Clock) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddClock ¶
AddClock will add the provided number of clock hours to the given time, taking things like DST into account.
func HoursBetween ¶
HoursBetween will return the number of full hours from a to b with respect to clock time and DST.
It is assumed a and b are of the same location.
func NextWeekday ¶
NextWeekday will return t at the start of the next weekday w. The returned value will always be in the future.
func PrevWeekday ¶
PrevWeekday will return t at the start of the most recent weekday w. The returned value will be identical if it is already the start of the requested weekday.
Types ¶
type Clock ¶
Clock represents wall-clock time. It is a duration since midnight.
func ClockDiff ¶
ClockDiff will return the amount of clock time from a to b with respect to DST.
It is assumed a and b are of the same location.
func IsDST ¶
IsDST will return true if there is a DST change within 24-hours AFTER t.
If so, the clock-time and amount of change is calculated.
func NewClockFromTime ¶
NewClockFromTime will return the Clock value of the provided time.
func ParseClock ¶
ParseClock will return a new Clock value given a value in the format of '15:04' or '15:04:05'. The resulting value will be truncated to the minute.
func (Clock) FirstOfDay ¶
FirstOfDay will return the first timestamp where the time matches the clock value, or the first instant after, if it does not exist.
func (Clock) Format ¶
Format will format the clock value using the same format string used by time.Time.
func (Clock) LastOfDay ¶
LastOfDay will return the last timestamp where the time matches the clock value, or the first instant after, if it does not exist.