Documentation ¶
Index ¶
- Constants
- type Date
- func (d Date) Add(years, months, days int) Date
- func (d Date) After(u Date) bool
- func (d Date) AppendFormat(b []byte, layout string) []byte
- func (d Date) Before(u Date) bool
- func (d Date) Day() int
- func (d Date) Equal(u Date) bool
- func (d Date) Format(format string) string
- func (d Date) IsZero() bool
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) Month() time.Month
- func (d *Date) Scan(value interface{}) error
- func (d Date) String() string
- func (d Date) Sub(u Date) ElapsedDays
- func (d Date) ToTime() time.Time
- func (d Date) Unix() int64
- func (d *Date) UnmarshalJSON(data []byte) error
- func (d Date) Value() (driver.Value, error)
- func (d Date) Year() int
- func (d Date) YearDay() int
- type ElapsedDays
- type NullDate
- func (nd NullDate) Format(layout string) string
- func (nd NullDate) IsZero() bool
- func (nd NullDate) MarshalJSON() ([]byte, error)
- func (nd NullDate) Ptr() *Date
- func (nd *NullDate) Scan(value interface{}) error
- func (nd *NullDate) SetValid(v Date)
- func (nd NullDate) String() string
- func (nd *NullDate) UnmarshalJSON(data []byte) error
- func (nd NullDate) Value() (driver.Value, error)
- func (nd NullDate) ValueOrZero() Date
Constants ¶
const ( ANSIC = "Jan _2 2006" RubyDate = "Jan 02 2006" RFC822 = "02 Jan 06" RFC3339 = "2006-01-02" )
These are string format for Date
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Date ¶
type Date struct {
// contains filtered or unexported fields
}
Date represents date under the proleptic Gregorian calendar used by ISO 8601. Zero value is 1, January, 1. In v1.0.0, formatting BC (e.g. "-0912-01-01") is unsupported. (Please contribute!)
func NewFromElapsedDays ¶ added in v1.0.0
func NewFromElapsedDays(ed ElapsedDays) Date
NewFromElapsedDays returns Date generated from ElapsedDate value
func NewFromTime ¶ added in v0.1.2
NewFromTime returns Date generated from time.Time's value
func (Date) AppendFormat ¶
AppendFormat is wrapper of AppendFormat method of time.Time
func (Date) Equal ¶
Equal reports whether d and u represent the same time instant. This is an alias of == operator.
func (Date) Format ¶
Format is wrapper of Format method of time.Time When IsZero is true, returns an empty string
func (Date) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface. The date is a quoted string in RFC 3339 format.
func (Date) Unix ¶
Unix returns d as a Unix time, the number of seconds elapsed Date.Unix() should calculate Unix time not including time.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaller interface. The date is expected to be a quoted string in RFC 3339 format.
type ElapsedDays ¶ added in v1.0.0
type ElapsedDays int64
ElapsedDays represents elapsed date based on 1, January, 1
const ZeroDays ElapsedDays = 0
ZeroDays represents 1, January, 1
func Since ¶
func Since(d Date) ElapsedDays
Since returns the days elapsed since d. It is shorthand for godate.Today().Sub(d).
type NullDate ¶
NullDate represents a date that may be null.
func NewNullDate ¶
NewNullDate creates a new NullDate.
func NullDateFrom ¶
NullDateFrom creates a new NullDate that will always be valid.
func NullDateFromPtr ¶
NullDateFromPtr creates a new NullDate that will be null if d is nil.
func (NullDate) MarshalJSON ¶
MarshalJSON implements json.Marshaller. It will encode null if this date is null.
func (NullDate) Ptr ¶
Ptr returns a pointer to this Date's value, or a nil pointer if this Date is null.
func (*NullDate) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaller.
func (NullDate) ValueOrZero ¶ added in v1.0.0
ValueOrZero returns the inner value if valid, otherwise zero.