Documentation
¶
Index ¶
- func RangeNotEmpty(dr Range) bool
- type ByAsc
- type Date
- func (d Date) AddDays(n int) Date
- func (d Date) AddDuration(dr time.Duration) Date
- func (d Date) AddMonths(n int) Date
- func (d Date) After(p Date) bool
- func (d Date) Before(p Date) bool
- func (d Date) DaysSince(s Date) (days int)
- func (d Date) Equal(d2 Date) bool
- func (d Date) FirstDayOfMonth() Date
- func (d Date) In(loc *time.Location) time.Time
- func (d Date) IsValid() bool
- func (d Date) LastDayOfMonth() Date
- func (d Date) MarshalText() ([]byte, error)
- func (d *Date) Scan(value interface{}) error
- func (d Date) String() string
- func (d *Date) UnmarshalText(data []byte) error
- func (d Date) Value() (driver.Value, error)
- type Range
- type RangeSet
- func (a RangeSet) ExtendEnd() RangeSet
- func (a RangeSet) Filter(test RangeTest) RangeSet
- func (a RangeSet) FilterEmpty() RangeSet
- func (a RangeSet) Impose(dr ...Range) RangeSet
- func (a RangeSet) ImposeSet(set RangeSet) RangeSet
- func (a RangeSet) List() []Range
- func (a RangeSet) ShiftEnd(n int) RangeSet
- func (a RangeSet) Sub(dr ...Range) RangeSet
- func (a RangeSet) SubSet(set RangeSet) RangeSet
- func (a RangeSet) TrimEnd() RangeSet
- type RangeTest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ByAsc ¶
type ByAsc []Date
ByAsc sorting type - used to sort Date slice from the earliest to the latest
type Date ¶
type Date struct { Year int // Year (e.g., 2014). Month time.Month // Month of the year (January = 1, ...). Day int // Day of the month, starting at 1. }
A Date represents a date (year, month, day).
This type does not include location information, and therefore does not describe a unique 24-hour timespan.
func Parse ¶
Parse parses a string in RFC3339 full-date format and returns the date value it represents.
func (Date) AddDays ¶
AddDays returns the date that is n days in the future. n can also be negative to go into the past.
func (Date) AddDuration ¶ added in v0.0.4
AddDuration returns the date by appending dr to d. dr can also be negative to go into the past.
func (Date) AddMonths ¶ added in v0.0.4
AddMonths returns the date that is n months in the future. n can also be negative to go into the past.
func (Date) DaysSince ¶
DaysSince returns the signed number of days between the date and s, not including the end day. This is the inverse operation to AddDays.
func (Date) FirstDayOfMonth ¶ added in v0.0.4
FirstDayOfMonth returns the first day of month for d.
func (Date) In ¶
In returns the time corresponding to time 00:00:00 of the date in the location.
In is always consistent with time.Date, even when time.Date returns a time on a different day. For example, if loc is America/Indiana/Vincennes, then both
time.Date(1955, time.May, 1, 0, 0, 0, 0, loc)
and
date.Date{Year: 1955, Month: time.May, Day: 1}.In(loc)
return 23:00:00 on April 30, 1955.
In panics if loc is nil.
func (Date) LastDayOfMonth ¶ added in v0.0.4
LastDayOfMonth returns the last day of month for d.
func (Date) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. The output is the result of d.String().
func (*Date) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. The date is expected to be a string in a format accepted by ParseDate.
type Range ¶
Range represents range between two dates.
func (Range) Encloses ¶
Encloses returns true if the bounds of the inner range do not extend outside the bounds of the outer range.
func (Range) Intersects ¶ added in v0.0.3
Intersects returns true if r/dr contains any of dr/r bounds.
type RangeSet ¶
type RangeSet []Range
RangeSet used to works with date ranges list.
func (RangeSet) FilterEmpty ¶
FilterEmpty returns RangeSet with not empty Ranges from a.
func (RangeSet) Impose ¶
Impose returns RangeSet after dr imposition. Range intersections will be merged: [10, 15] impose with [13, 22] got [10, 22] [10, 15] impose with [20, 25] got [10, 15], [20, 25]
func (RangeSet) ShiftEnd ¶
ShiftEnd shifts end date to n days. n can also be negative to go into the past.