Documentation ¶
Index ¶
- Constants
- Variables
- type Date
- func From(t time.Time) Date
- func FromIn(t time.Time, locationName string) (Date, error)
- func FromInLoc(t time.Time, loc *time.Location) Date
- func FromInMust(t time.Time, locationName string) Date
- func FromProto(p ProtoDate) Date
- func MustParse(s string) Date
- func MustTodayIn(locationName string) Date
- func New(year int, month time.Month, day int) Date
- func Parse(s string) (Date, bool)
- func Today() Date
- func TodayIn(locationName string) (Date, error)
- func TodayInLoc(loc *time.Location) 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) Earliest(other Date) Date
- func (d Date) Equal(other Date) bool
- func (d Date) Format(layout string) string
- func (d Date) GoString() 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) Latest(other Date) Date
- func (d Date) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) MarshalText() ([]byte, error)
- func (d Date) Max(other Date) Date
- 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) UnmarshalText(text []byte) error
- func (d Date) Weekday() time.Weekday
- func (d Date) Year() int
- type ProtoDate
Constants ¶
const RFC3339Date = `2006-01-02`
const RFC3339DateJSON = `"` + RFC3339Date + `"`
Variables ¶
var Empty = Date{}
Empty is the zero value for a date. It is January 1, year 1, UTC.
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 FromIn ¶
FromIn returns a new date from the given time in the given location name. The time is truncated to the day.
func FromInLoc ¶
FromInLoc returns a new date from the given time in the given location. The time is truncated to the day.
func FromInMust ¶
FromInMust returns a new date from the given time in the given location name. The time is truncated to the day.
func MustParse ¶
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 MustTodayIn ¶
MustTodayIn returns the current date in the given location name. If locationName is invalid, it panics.
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 TodayIn ¶
TodayIn returns the current date in the given location name. If locationName is invalid, an error is returned.
func TodayInLoc ¶
TodayInLoc returns the current date in the given location. It is a convenience function for From(time.Now().In(loc)).
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 ¶
AsNullable returns the date as a nullable date (pointer to).
func (Date) IsBetween ¶
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) MarshalText ¶
MarshalText Implements encoding.TextMarshaler for Date
func (Date) NonZeroMin ¶
func (*Date) UnmarshalBSONValue ¶
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Converts from "yyyy-MMM-dd" format.
func (*Date) UnmarshalText ¶
UnmarshalText Implements encoding.TextUnmarshaler for Date