Documentation ¶
Index ¶
- Constants
- Variables
- func AddDate(year, month, day int64, ot gotime.Time) (nt gotime.Time)
- func DateDiff(startTime, endTime CoreTime) int
- func GetLastDay(year, month int) int
- type CoreTime
- func (t CoreTime) Day() int
- func (t CoreTime) GoTime(loc *gotime.Location) (gotime.Time, error)
- func (t CoreTime) Hour() int
- func (t CoreTime) IsLeapYear() bool
- func (t CoreTime) Microsecond() int
- func (t CoreTime) Minute() int
- func (t CoreTime) Month() int
- func (t CoreTime) Second() int
- func (t CoreTime) String() string
- func (t CoreTime) Week(mode int) int
- func (t CoreTime) Weekday() gotime.Weekday
- func (t CoreTime) Year() int
- func (t CoreTime) YearDay() int
- func (t CoreTime) YearWeek(mode int) (year int, week int)
- type Time
Constants ¶
const ( // UnspecifiedFsp is the unspecified fractional seconds part. UnspecifiedFsp = int8(-1) // MaxFsp is the maximum digit of fractional seconds part. MaxFsp = int8(6) // MinFsp is the minimum digit of fractional seconds part. MinFsp = int8(0) // DefaultFsp is the default digit of fractional seconds part. // MySQL use 0 as the default Fsp. DefaultFsp = int8(0) )
const ( TypeUnspecified byte = 0 TypeTiny byte = 1 TypeShort byte = 2 TypeLong byte = 3 TypeFloat byte = 4 TypeDouble byte = 5 TypeNull byte = 6 TypeTimestamp byte = 7 TypeLonglong byte = 8 TypeInt24 byte = 9 TypeDate byte = 10 /* TypeDuration original name was TypeTime, renamed to TypeDuration to resolve the conflict with Go type Time.*/ TypeDuration byte = 11 TypeDatetime byte = 12 TypeYear byte = 13 TypeNewDate byte = 14 TypeVarchar byte = 15 TypeBit byte = 16 TypeJSON byte = 0xf5 TypeNewDecimal byte = 0xf6 TypeEnum byte = 0xf7 TypeSet byte = 0xf8 TypeTinyBlob byte = 0xf9 TypeMediumBlob byte = 0xfa TypeLongBlob byte = 0xfb TypeBlob byte = 0xfc TypeVarString byte = 0xfd TypeString byte = 0xfe TypeGeometry byte = 0xff )
MySQL type information.
Variables ¶
var ZeroCoreTime = CoreTime(0)
ZeroCoreTime is the zero value for TimeInternal type.
var ( // ZeroCoreTime is the zero value for Time type. ZeroTime = Time{} )
Zero values for different types.
Functions ¶
func AddDate ¶
AddDate fix gap between mysql and golang api When we execute select date_add('2018-01-31',interval 1 month) in mysql we got 2018-02-28 but in tidb we got 2018-03-03. Dig it and we found it's caused by golang api time.Date(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time , it says October 32 converts to November 1 ,it conflicts with mysql. See https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_date-add
Types ¶
type CoreTime ¶
type CoreTime uint64
CoreTime is the internal struct type for Time.
func FromDate ¶
func FromDate(year int, month int, day int, hour int, minute int, second int, microsecond int) CoreTime
FromDate makes a internal time representation from the given date.
func FromGoTime ¶
FromGoTime translates time.Time to mysql time internal representation.
func (CoreTime) IsLeapYear ¶
IsLeapYear returns if it's leap year.
func (CoreTime) Microsecond ¶
Microsecond returns the microsecond value.