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) AddWeeks(amount int) Date
- func (d Date) Copy() 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) SetDay(day int) Date
- func (d Date) SetMonth(month time.Month) Date
- func (d Date) SetUnix(sec int64) Date
- func (d Date) SetYear(year int) Date
- func (d Date) StartOfMonth() Date
- func (d Date) StartOfYear() Date
- func (d Date) String() string
- func (d Date) Sub(t Date) time.Duration
- func (d Date) ToDateTime() DateTime
- 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) AddWeeks(amount int) DateTime
- func (d DateTime) Copy() 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) SetDay(day int) DateTime
- func (d DateTime) SetHour(hour int) DateTime
- func (d DateTime) SetMinute(min int) DateTime
- func (d DateTime) SetMonth(month time.Month) DateTime
- func (d DateTime) SetSecond(sec int) DateTime
- func (d DateTime) SetUnix(sec int64) DateTime
- func (d DateTime) SetYear(year int) DateTime
- func (d DateTime) StartOfDay() DateTime
- func (d DateTime) StartOfHour() DateTime
- func (d DateTime) StartOfMonth() DateTime
- func (d DateTime) StartOfYear() DateTime
- 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"
)
const (
// 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 ¶
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
func (Date) StartOfMonth ¶
StartOfMonth returns the date corresponding to the first day of d's current month
func (Date) StartOfYear ¶
StartOfYear returns the date corresponding to the first day of d's year
func (Date) 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).
func (Date) ToDateTime ¶
ToDateTime returns the Date of this DateTime
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 ¶
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) StartOfDay ¶
StartOfDay returns the DateTime corresponding to the beginning of the day, at 00:00
func (DateTime) StartOfHour ¶
StartOfHour returns the DateTime corresponding to the beginning of the current hour
func (DateTime) StartOfMonth ¶
StartOfMonth returns the DateTime corresponding to the first day of d's current month at 00:00
func (DateTime) StartOfYear ¶
StartOfYear returns the DateTime corresponding to the first day of d's year at 00:00
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).