Documentation
¶
Overview ¶
Package frdate has functions to manage reservation dates and record timestamps.
In general the fr code should not use time package but only these functions.
Also this package should not accept or return "time" objects.
Date or DateTime objects are used for calendar dates and timestamps respectively.
Date or DateTime objects are built with a DataBuilder which requires the location.
Date objects are persisted with strings in the iso8601format layout (see below).
DateTime objects are persisted with strings in the time.RFC3339 layout (see time package).
Index ¶
- Variables
- func CreateDateTimeUTC() string
- func DateOverlap(first1 *Date, last1 *Date, first2 *Date, last2 *Date) bool
- func DateOverlapInOut(inDate1 *Date, outDate1 *Date, inDate2 *Date, outDate2 *Date) bool
- type Date
- func (r *Date) AddDays(num int) *Date
- func (r *Date) After(date *Date) bool
- func (r *Date) Before(date *Date) bool
- func (r *Date) Copy() *Date
- func (r *Date) Equal(date *Date) bool
- func (r *Date) Format(layout string) string
- func (r *Date) MonthInOut() (*Date, *Date)
- func (r *Date) Sub(start *Date) int
- func (r *Date) ToString() string
- func (r *Date) ToStringPtr() *string
- func (r *Date) Year() int
- func (r *Date) YearInOut() (*Date, *Date)
- type DateBuilder
- func (r *DateBuilder) MustNewDate(iso8601short string) *Date
- func (r *DateBuilder) MustNewDateTime(rfc3339datetime string) *DateTime
- func (r *DateBuilder) NewDate(iso8601short string) (*Date, error)
- func (r *DateBuilder) NewDateTime(rfc3339datetime string) (*DateTime, error)
- func (r *DateBuilder) Today() *Date
- type DateTime
- func (r *DateTime) AddDays(num int) *DateTime
- func (r *DateTime) After(date *DateTime) bool
- func (r *DateTime) Before(date *DateTime) bool
- func (r *DateTime) Equal(date *DateTime) bool
- func (r *DateTime) Format(layout string) string
- func (r *DateTime) ToDate() *Date
- func (r *DateTime) ToString() string
- func (r *DateTime) ToStringPtr() *string
Constants ¶
This section is empty.
Variables ¶
var TestTimeOffsetDays *int
TestTimeOffsetDays is the time offset used during testing
Functions ¶
func CreateDateTimeUTC ¶
func CreateDateTimeUTC() string
CreateDateTimeUTC is used for all timestamps in the project
func DateOverlap ¶
DateOverlap returns true if there exists an overlap between the first and second date ranges
Types ¶
type Date ¶
type Date struct {
// contains filtered or unexported fields
}
Date represents a calendar date
func MustNewDate ¶
MustNewDate produces a Date given a location and date string or panics on error
func (*Date) Format ¶
Format produces a string representation of a Date based on the layout argument
func (*Date) MonthInOut ¶
MonthInOut produces the first Date of the current month, and the first Date of the following month
func (*Date) ToStringPtr ¶
ToStringPtr returns a pointer to an iso string representation of a Date
type DateBuilder ¶
type DateBuilder struct {
// contains filtered or unexported fields
}
DateBuilder is the base struct for creating Date or DateTime objects
func MustNewDateBuilder ¶
func MustNewDateBuilder(location string) *DateBuilder
MustNewDateBuilder creates a new DateBuilder given a location or panics on error
func NewDateBuilder ¶
func NewDateBuilder(location string) (*DateBuilder, error)
NewDateBuilder creates a new DateBuilder given a location or returns an error
func (*DateBuilder) MustNewDate ¶
func (r *DateBuilder) MustNewDate(iso8601short string) *Date
MustNewDate produces a Date given the date string, or panics
func (*DateBuilder) MustNewDateTime ¶
func (r *DateBuilder) MustNewDateTime(rfc3339datetime string) *DateTime
MustNewDateTime produces a DateTime given the date-time string, or panics
func (*DateBuilder) NewDate ¶
func (r *DateBuilder) NewDate(iso8601short string) (*Date, error)
NewDate produces a Date given the date string, or returns an error
func (*DateBuilder) NewDateTime ¶
func (r *DateBuilder) NewDateTime(rfc3339datetime string) (*DateTime, error)
NewDateTime produces a DateTime given the date-time string, or returns an error
type DateTime ¶
type DateTime struct {
// contains filtered or unexported fields
}
DateTime represents a date plus time, ex. for use as a timestamp
func (*DateTime) Format ¶
Format produces a string representation of a DateTime based on the layout argument
func (*DateTime) ToStringPtr ¶
ToStringPtr returns a pointer to an rfc string representation of a DateTime