Documentation ¶
Overview ¶
Package cal provides simple date handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DateAfter ¶
func DateAfter(date Date) validation.Rule
DateAfter returns a validation rule which checks to ensure the date is *after* the provided date.
func DateBefore ¶
func DateBefore(date Date) validation.Rule
DateBefore is used during validation to ensure the date is before the value passed in.
func DateNotZero ¶
func DateNotZero() validation.Rule
DateNotZero ensures the date is not a zero value.
func DateTimeAfter ¶ added in v0.56.0
func DateTimeAfter(dt DateTime) validation.Rule
DateTimeAfter returns a validation rule which checks to ensure the date is *after* the provided date.
func DateTimeBefore ¶ added in v0.56.0
func DateTimeBefore(dt DateTime) validation.Rule
DateTimeBefore is used during validation to ensure the date is before the value passed in.
func DateTimeNotZero ¶ added in v0.56.0
func DateTimeNotZero() validation.Rule
DateTimeNotZero ensures the date is not a zero value.
Types ¶
type Date ¶
Date represents a simple date without time used most frequently with business documents.
func DateOf ¶ added in v0.52.4
DateOf returns the Date in which a time occurs in the time's location.
func TodayIn ¶ added in v0.40.0
TodayIn generates a new date instance for today in the given location.
func (Date) Add ¶ added in v0.52.4
Add returns a new date with the given number of years, months and days. This uses the time package to do the arithmetic.
func (Date) JSONSchema ¶
func (Date) JSONSchema() *jsonschema.Schema
JSONSchema returns a custom json schema for the date.
func (Date) TimeIn ¶ added in v0.52.4
TimeIn returns a time object for the date in the given location which may be important when considering timezones and arithmetic.
func (*Date) UnmarshalJSON ¶ added in v0.39.0
UnmarshalJSON is used to parse a date from json and ensures that we can handle invalid data reasonably.
type DateTime ¶ added in v0.56.0
DateTime represents a combination of date and time without location specific information nor support for millisecond precision.
func DateTimeOf ¶ added in v0.56.0
DateTimeOf returns the DateTime from the provided time.
func MakeDateTime ¶ added in v0.56.0
MakeDateTime provides a new date time instance.
func NewDateTime ¶ added in v0.56.0
NewDateTime provides a pointer to a new date time instance.
func ThisSecond ¶ added in v0.56.0
func ThisSecond() DateTime
ThisSecond produces a new date time instance for the current UTC time to the nearest second.
func ThisSecondIn ¶ added in v0.56.0
ThisSecondIn provides a new date time using the current time from the provided location as a reference.
func (DateTime) In ¶ added in v0.56.0
In returns a new time.Time instance with the provided location.
func (DateTime) JSONSchema ¶ added in v0.56.0
func (DateTime) JSONSchema() *jsonschema.Schema
JSONSchema returns a custom json schema for the date time.
func (DateTime) TimeZ ¶ added in v0.56.0
TimeZ returns a new time.Time instance with the UTC location.
func (*DateTime) UnmarshalJSON ¶ added in v0.56.0
UnmarshalJSON is used to parse a date from json and ensures that we can handle invalid data reasonably.
type Period ¶
type Period struct { // Label is a short description of the period. Label string `json:"label,omitempty" jsonschema:"title=Label"` // Start indicates when this period starts. Start Date `json:"start" jsonschema:"title=Start"` // End indicates when the period ends, and must be after the start date. End Date `json:"end" jsonschema:"title=End"` }
Period represents two dates with a start and finish.