Documentation ¶
Index ¶
- Constants
- Variables
- func DayToUTCRange(d time.Time, tz *time.Location) (time.Time, time.Time)
- func DaysBetween(date1 time.Time, date2 time.Time) int
- func FormatISO(date time.Time) string
- func MonthsBetween(date1 time.Time, date2 time.Time) int
- func Now() time.Time
- func SetNowSource(source NowSource)
- type Date
- func (d Date) Combine(timeOfDay TimeOfDay, tz *time.Location) time.Time
- func (d Date) Compare(other Date) int
- func (d Date) Equal(other Date) bool
- func (d Date) Format(layout string) string
- func (d Date) String() string
- func (d Date) WeekNum() int
- func (d Date) Weekday() time.Weekday
- func (d Date) YearDay() int
- type NowSource
- type TimeOfDay
Constants ¶
const (
ISO8601Date = "2006-01-02"
)
Variables ¶
var ZeroDate = Date{}
ZeroDate is our uninitialized date value
var ZeroTimeOfDay = TimeOfDay{}
ZeroTimeOfDay is our uninitialized time of day value
Functions ¶
func DayToUTCRange ¶
DayToUTCRange returns the UTC time range of the given day
func DaysBetween ¶
DaysBetween returns the number of calendar days (an int) between the two dates. Note that if these are in different timezones then the local calendar day is used for each and the difference is calculated from that.
func MonthsBetween ¶
MonthsBetween returns the number of calendar months (an int) between the two dates. Note that if these are in different timezones then the local calendar day is used for each and the difference is calculated from that.
func SetNowSource ¶
func SetNowSource(source NowSource)
SetNowSource sets the time source used by Now()
Types ¶
type Date ¶
Date is a local gregorian calendar date
func ExtractDate ¶
ExtractDate extracts the date from the give datetime
type NowSource ¶
NowSource is something that can provide a now result
var DefaultNowSource NowSource = defaultNowSource{}
DefaultNowSource is the default time source
func NewFixedNowSource ¶
NewFixedNowSource creates a new fixed time now source
func NewSequentialNowSource ¶
NewSequentialNowSource creates a new sequential time source
type TimeOfDay ¶
TimeOfDay represents a local time of day value
func ExtractTimeOfDay ¶
ExtractTimeOfDay extracts the time of day from the give datetime
func NewTimeOfDay ¶
NewTimeOfDay creates a new time of day
func ParseTimeOfDay ¶
ParseTimeOfDay parses the given string into a time of day