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 ¶ 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
func (Date) SetMonth ¶ added in v0.0.9
SetMonth changes the month value of d returns d for chained calls
func (Date) SetUnix ¶ added in v0.0.9
SetUnix returns the date corresponding to the given unix timestamp
func (Date) SetYear ¶ added in v0.0.9
SetYear changes the year value of d returns d for chained calls
func (Date) StartOfMonth ¶ added in v0.0.9
StartOfMonth returns the date corresponding to the first day of d's current month
func (Date) StartOfYear ¶ added in v0.0.9
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 ¶ added in v0.0.9
ToDate 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 ¶ 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) SetDay ¶ added in v0.0.9
SetDay changes the day value of d returns d for chained calls
func (DateTime) SetHour ¶ added in v0.0.9
SetHour changes the hour value of d returns d for chained calls
func (DateTime) SetMinute ¶ added in v0.0.9
SetMinute changes the minute value of d returns d for chained calls
func (DateTime) SetMonth ¶ added in v0.0.9
SetMonth changes the month value of d returns d for chained calls
func (DateTime) SetSecond ¶ added in v0.0.9
SetSecond changes the second value of d returns d for chained calls
func (DateTime) SetUnix ¶ added in v0.0.9
SetUnix returns the DateTime corresponding to the given unix timestamp
func (DateTime) SetYear ¶ added in v0.0.9
SetYear changes the year value of d returns d for chained calls
func (DateTime) StartOfDay ¶ added in v0.0.9
StartOfYear returns the DateTime corresponding to the beginning of the day, at 00:00
func (DateTime) StartOfHour ¶ added in v0.0.9
StartOfMonth returns the DateTime corresponding to the beginning of the current our
func (DateTime) StartOfMonth ¶ added in v0.0.9
StartOfMonth returns the DateTime corresponding to the first day of d's current month at 00:00
func (DateTime) StartOfYear ¶ added in v0.0.9
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).