Documentation ¶
Index ¶
- Constants
- func RemoveTime(t time.Time) time.Time
- type Date
- func (d Date) AddDate(year, month, day int) Date
- func (d Date) AddMonths(n int) Date
- func (d Date) After(ref Date) bool
- func (d Date) Before(ref Date) bool
- func (d Date) Day() int
- func (d Date) DaysOfMonth() int
- func (d Date) DiffMonths(ref Date) int
- func (d Date) Equal(ref Date) bool
- func (d Date) GormDataType() string
- func (d Date) IsZero() bool
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) Month() time.Month
- func (d *Date) Scan(value interface{}) (err error)
- func (d Date) String() string
- func (d Date) Sub(ref Date) time.Duration
- func (d Date) ToTime() time.Time
- func (d *Date) UnmarshalJSON(bs []byte) error
- func (d Date) Value() (driver.Value, error)
- func (d Date) YMD() (year int, month time.Month, day int)
- func (d Date) Year() int
Constants ¶
const RFC3339Date = "2006-01-02"
RFC3339Date format
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Date ¶
Date is the non-nullable type for Date only. Support UTC timezone only
func MustParse ¶
MustParse creates a new Date from the RFC3339 Date - "2006-01-02" Panic if wrong format
func NewFromStr ¶
NewFromStr creates a new Date from the RFC3339 Date - "2006-01-02"
func (Date) AddDate ¶
AddDate returns the Date corresponding to adding the given number of years, months, and days to d. For example, AddDate(-1, 2, 3) applied to January 1, 2011 returns March 4, 2010.
AddDate normalizes its result in the same way that Date does, so, for example, adding one month to October 31 yields December 1, the normalized form for November 31.
func (Date) AddMonths ¶
AddMonths return add the number of months. If the day at this month > maxDay (like 30 for Feb), it will be the last day of this month
func (Date) DaysOfMonth ¶
DaysOfMonth returns total days in the month of the Date
func (Date) DiffMonths ¶
DiffMonths to calculate the diff of months If date.After(ref) -> Return negative If date.Before(ref) -> Return positive Id date.Equal(ref) -> Return 1 a.DiffMonths(b) may != b.DiffMonths(a) because of the last day of month
func (Date) MarshalJSON ¶
MarshalJSON marshal to the JSON
func (*Date) UnmarshalJSON ¶
UnmarshalJSON to parse the JSON