Documentation
¶
Index ¶
- Constants
- Variables
- func LoadLocation(name string) (*time.Location, error)
- func TimeZones() []string
- type Date
- func (d Date) AddDate(years, months, days int) Date
- func (d Date) Equal(other Date) bool
- func (d Date) Greater(other Date) bool
- func (d Date) GreaterEqual(other Date) bool
- func (d Date) Lower(other Date) bool
- func (d Date) LowerEqual(other Date) bool
- func (d Date) MarshalJSON() ([]byte, error)
- func (d *Date) Scan(src interface{}) error
- func (d Date) String() string
- func (d Date) Sub(t Date) time.Duration
- func (d Date) Value() (driver.Value, error)
- type DateTime
- func (d DateTime) Add(duration time.Duration) DateTime
- func (d DateTime) AddDate(years, months, days int) DateTime
- func (d DateTime) Equal(other DateTime) bool
- func (d DateTime) Greater(other DateTime) bool
- func (d DateTime) GreaterEqual(other DateTime) bool
- func (d DateTime) In(loc *time.Location) DateTime
- func (d DateTime) Lower(other DateTime) bool
- func (d DateTime) LowerEqual(other DateTime) bool
- func (d DateTime) MarshalJSON() ([]byte, error)
- func (d *DateTime) Scan(src interface{}) error
- func (d DateTime) String() string
- func (d DateTime) Sub(t DateTime) time.Duration
- func (d DateTime) ToDate() Date
- func (d DateTime) UTC() DateTime
- func (d DateTime) Value() (driver.Value, error)
- func (d DateTime) WithTimezone(tz string) (DateTime, error)
Constants ¶
const ( // DefaultServerDateFormat is the Go layout for Date objects DefaultServerDateFormat = "2006-01-02" // DefaultServerDateTimeFormat is the Go layout for DateTime objects DefaultServerDateTimeFormat = "2006-01-02 15:04:05" )
Variables ¶
var TimeZoneList = []string{}/* 592 elements not displayed */
TimeZoneList is the list of all known time zones. Use this var if you need to add a new TimeZone, but Call dates.TimeZones to get the list.
Functions ¶
func LoadLocation ¶ added in v0.0.6
LoadLocation returns the Location with the given name.
If the name is "" or "UTC", LoadLocation returns UTC. If the name is "Local", LoadLocation returns Local.
Otherwise, the name is taken to be a location name corresponding to a file in the IANA Time Zone database, such as "America/New_York".
Types ¶
type Date ¶
Date type that JSON marshal and unmarshals as "YYYY-MM-DD"
func ParseDate ¶
ParseDate returns a date from the given string value that is formatted with the default YYYY-MM-DD format.
It panics in case the parsing cannot be done.
func ParseDateWithLayout ¶
ParseDateWithLayout returns a date from the given string value that is formatted with layout.
func (Date) GreaterEqual ¶
GreaterEqual returns true if d is greater than or equal to other
func (Date) LowerEqual ¶
LowerEqual returns true if d is lower than or equal to other
type DateTime ¶
DateTime type that JSON marshals and unmarshals as "YYYY-MM-DD HH:MM:SS"
func ParseDateTime ¶
ParseDateTime returns a datetime from the given string value that is formatted with the default YYYY-MM-DD HH:MM:SSformat.
It panics in case the parsing cannot be done.
func ParseDateTimeWithLayout ¶
ParseDateTimeWithLayout returns a datetime from the given string value that is formatted with layout.
func (DateTime) GreaterEqual ¶
GreaterEqual returns true if d is greater than or equal to other
func (DateTime) In ¶ added in v0.0.6
In returns d with the location information set to loc. In panics if loc is nil.
func (DateTime) LowerEqual ¶
LowerEqual returns true if d is lower than or equal to other
func (DateTime) MarshalJSON ¶
MarshalJSON for DateTime type
func (DateTime) Sub ¶
Sub returns the duration t-u. If the result exceeds the maximum (or minimum) value that can be stored in a Duration, the maximum (or minimum) duration will be returned. To compute t-d for a duration d, use t.Add(-d).