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) Day() int
- func (d Date) Format(layout string) string
- func (d Date) IsZero() bool
- func (d Date) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) Month() time.Month
- 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 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) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. Converts to "yyyy-MMM-dd" format.
func (*Date) UnmarshalBSONValue ¶
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Converts from "yyyy-MMM-dd" format.