Documentation ¶
Index ¶
- Constants
- Variables
- type Date
- func (d Date) Add(duration time.Duration) Date
- func (d Date) AddDate(years int, months int, days int) Date
- func (d Date) AddDays(days int) Date
- func (d Date) After(other Date) bool
- func (d Date) AsNullable() *Date
- func (d Date) Before(other Date) bool
- func (d Date) Day() int
- func (d Date) Equal(other Date) bool
- func (d Date) Format(layout string) string
- func (d Date) IsAfter(date Date) bool
- func (d Date) IsBefore(date Date) bool
- func (d Date) IsBetween(start, end Date) bool
- func (d Date) IsEqual(date Date) bool
- func (d Date) IsZero() bool
- func (d Date) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) Min(other Date) Date
- func (d Date) Month() time.Month
- func (d Date) NonZeroMin(other Date) Date
- func (d Date) String() string
- func (d Date) Sub(other Date) int
- func (d Date) Time() time.Time
- func (d *Date) UnmarshalBSONValue(t bsontype.Type, data []byte) error
- func (d *Date) UnmarshalJSON(b []byte) error
- func (d Date) Weekday() time.Weekday
- func (d Date) Year() int
Constants ¶
const RFC3339Date = `2006-01-02`
const RFC3339DateJSON = `"` + RFC3339Date + `"`
Variables ¶
var ErrInvalidDate = errors.New("invalid date")
Functions ¶
This section is empty.
Types ¶
type Date ¶
type Date struct {
// contains filtered or unexported fields
}
Date represents a date without time. It is a wrapper around time.Time.
func MustParse ¶ added in v0.25.2
MustParse parses a date in RFC3339 format (yyyy-mm-dd) and panics if the date is invalid. It is intended for use in variable initializations and tests.
func Today ¶
func Today() Date
Today returns the current date in UTC. It is a convenience function for From(time.Now()). It is equivalent to the current day at 00:00 time.
func (Date) Add ¶
Add returns the date with the given duration added. Only the date part is used, the time part is ignored.
func (Date) AddDate ¶
AddDate returns the date with the given number of years, months and days added. To subtract, use negative values.
func (Date) AddDays ¶
AddDays returns the date with the given number of days added. To subtract, use negative values.
func (Date) AsNullable ¶ added in v0.25.0
AsNullable returns the date as a nullable date (pointer to).
func (Date) IsBetween ¶ added in v0.32.0
IsBetween reports whether the date is between the start and end dates (not inclusive).
func (Date) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. Converts to "yyyy-MMM-dd" format.
func (Date) NonZeroMin ¶ added in v0.20.0
func (Date) Sub ¶ added in v0.32.0
Sub returns the number of days between this date and the other date.
func (*Date) UnmarshalBSONValue ¶
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Converts from "yyyy-MMM-dd" format.