Documentation ¶
Index ¶
- Constants
- Variables
- type Date
- func (d Date) After(u Date) bool
- func (d Date) Before(u Date) bool
- func (d Date) Date() (int, time.Month, int)
- func (d Date) Day() int
- func (d Date) Equal(u Date) bool
- func (d Date) IsZero() bool
- func (d Date) Local() time.Time
- func (d Date) Month() time.Month
- func (d *Date) Scan(src interface{}) (err error)
- func (d Date) String() string
- func (d Date) Time(loc *time.Location) (t time.Time)
- func (d Date) Value() (driver.Value, error)
- func (d Date) Weekday() time.Weekday
- func (d Date) Year() int
- func (d Date) YearDay() int
- type Datetime
- func (t Datetime) After(u Datetime) bool
- func (t Datetime) Before(u Datetime) bool
- func (t Datetime) Clock() (int, int, int)
- func (t Datetime) Date() (int, time.Month, int)
- func (t Datetime) Day() int
- func (t Datetime) Equal(u Datetime) bool
- func (t Datetime) Hour() int
- func (t Datetime) IsZero() bool
- func (t Datetime) Local() time.Time
- func (t Datetime) Minute() int
- func (t Datetime) Month() time.Month
- func (t *Datetime) Scan(src interface{}) (err error)
- func (t Datetime) Second() int
- func (t Datetime) String() string
- func (t Datetime) Time(loc *time.Location) (tt time.Time)
- func (t Datetime) Value() (driver.Value, error)
- func (t Datetime) Weekday() time.Weekday
- func (t Datetime) Year() int
- func (t Datetime) YearDay() int
- type Time
- func (t Time) After(u Time) bool
- func (t Time) Before(u Time) bool
- func (t Time) Clock() (int, int, int)
- func (t Time) Duration() time.Duration
- func (t Time) Equal(u Time) bool
- func (t Time) Hour() int
- func (t Time) IsZero() bool
- func (t Time) Local() time.Time
- func (t Time) Minute() int
- func (t *Time) Scan(src interface{}) (err error)
- func (t Time) Second() int
- func (t Time) String() string
- func (t Time) Time(loc *time.Location) time.Time
- func (t Time) Value() (driver.Value, error)
- type Year
- func (y Year) After(u Year) bool
- func (y Year) Before(u Year) bool
- func (y Year) Equal(u Year) bool
- func (y Year) IsZero() bool
- func (y Year) Local() time.Time
- func (y *Year) Scan(src interface{}) (err error)
- func (y Year) String() string
- func (y Year) Time(loc *time.Location) (t time.Time)
- func (y Year) Value() (driver.Value, error)
- func (y Year) Year() int
Constants ¶
const ( DateFormat = "2006-01-02" DatetimeFormat = "2006-01-02 15:04:05" TimeFormat = "15:04:05" YearFormat = "2006" )
The string formats.
const ( ZeroDate = "0000-00-00" ZeroDatetime = "0000-00-00 00:00:00" ZeroTime = "00:00:00" ZeroYear = "0000" )
The zero strings.
Variables ¶
var ( ErrDateParse = errors.New("Invalid Date string.") ErrDateRange = errors.New("Invalid Date range.") ErrDateScan = errors.New("Unable to convert value to a Date.") ErrDatetimeParse = errors.New("Invalid Datetime string.") ErrDatetimeRange = errors.New("Invalid Datetime range.") ErrDatetimeScan = errors.New("Unable to convert value to a Datetime.") ErrTimeParse = errors.New("Invalid Time string.") ErrTimeRange = errors.New("Invalid Time range.") ErrTimeScan = errors.New("Unable to convert value to a Time.") ErrYearParse = errors.New("Invalid Year string.") ErrYearRange = errors.New("Invalid Year range.") ErrYearScan = errors.New("Unable to convert value to a Year.") )
Common errors.
Functions ¶
This section is empty.
Types ¶
type Date ¶
Date represents a date. Dates are location independent.
func NewDate ¶
NewDate creates a new date using the given year, month, and day. The year must lie in the range 1000 to 9999, inclusive, or all arguments must be 0.
func ParseDate ¶
ParseDate converts the string format "YYYY-MM-DD" to a Date. Leading and trailing spaces are ignored.
func (*Date) Scan ¶
Scan assigns a value to this Date from a database driver. The src value should be one of the types defined in the sql.Scanner interface.
type Datetime ¶
Datetime represents a datetime. Datetimes are location independent.
func NewDatetime ¶
func NewDatetime(year int, month time.Month, day int, hour int, min int, sec int) (t Datetime, err error)
NewDatetime creates a new datetime using the given data. The year must lie in the range 1000 to 9999, inclusive, or all arguments must be 0.
func ParseDatetime ¶
ParseDatetime converts the string format "YYYY-MM-DD hh:mm:ss" to a Datetime. Leading and trailing spaces are ignored.
func TimeToDatetime ¶
TimeToDatetime creates a new datetime using the given time.Time. The year, month, etc. are read from the time.Time using its defined location.
func (*Datetime) Scan ¶
Scan assigns a value to this Datetime from a database driver. The src value should be one of the types defined in the sql.Scanner interface.
type Time ¶
Time represents a duration of time.
func DurationToTime ¶
DurationToTime creates a new time from the given duration.
func NewTime ¶
NewTime creates a new time using the given data. The number of hours must lie in the range -838 to 838, inclusive.
func ParseTime ¶
ParseTime converts the string format "[+-]h+:mm:ss" to a Time. Leading and trailing spaces are ignored.
func (*Time) Scan ¶
Scan assigns a value to this Time from a database driver. The src value should be one of the types defined in the sql.Scanner interface.
type Year ¶
type Year int
Year represents a year. Years are location independent.
func NewYear ¶
NewYear creates a new year. The year must lie in the range 1901 to 2155, inclusive, or be 0.
func (*Year) Scan ¶
Scan assigns a value to this Year from a database driver. The src value should be one of the types defined in the sql.Scanner interface.