func dateToUint64(t MysqlTime) uint64 {
	return uint64(t.Year())*10000 +
		uint64(t.Month())*100 +
		uint64(t.Day())
}
dateToUint64 converts time value to integer in YYYYMMDD format.
package types
import (
	gotime "time"
	"github.com/pingcap/errors"
)
type MysqlTime struct {
	year  uint16  
	month uint8   
	day   uint8   
	hour        int    
	minute      uint8  
	second      uint8  
	microsecond uint32
}
func (t MysqlTime) Year() int {
	return int(t.year)
}
func (t MysqlTime) Month() int {
	return int(t.month)
}
func (t MysqlTime) Day() int {
	return int(t.day)
}
func (t MysqlTime) Hour() int {
	return int(t.hour)
}
func (t MysqlTime) Minute() int {
	return int(t.minute)
}
func (t MysqlTime) Second() int {
	return int(t.second)
}
func (t MysqlTime) Microsecond() int {
	return int(t.microsecond)
}
func (t MysqlTime) Weekday() gotime.Weekday {
	t1, err := t.GoTime(gotime.Local)
	if err != nil {
		return 0
	}
	return t1.Weekday()
}
func (t MysqlTime) YearDay() int {
	if t.month == 0 || t.day == 0 {
		return 0
	}
	return calcDaynr(int(t.year), int(t.month), int(t.day)) -
		calcDaynr(int(t.year), 1, 1) + 1
}
func (t MysqlTime) YearWeek(mode int) (int, int) {
	behavior := weekMode(mode) | weekBehaviourYear
	return calcWeek(&t, behavior)
}
func (t MysqlTime) Week(mode int) int {
	if t.month == 0 || t.day == 0 {
		return 0
	}
	_, week := calcWeek(&t, weekMode(mode))
	return week
}
func (t MysqlTime) GoTime(loc *gotime.Location) (gotime.Time, error) {
	tm := gotime.Date(t.Year(), gotime.Month(t.Month()), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Microsecond()*1000, loc)
	year, month, day := tm.Date()
	hour, minute, second := tm.Clock()
	microsec := tm.Nanosecond() / 1000
	if year != t.Year() || int(month) != t.Month() || day != t.Day() ||
		hour != t.Hour() || minute != t.Minute() || second != t.Second() ||
		microsec != t.Microsecond() {
		return tm, errors.Trace(ErrInvalidTimeFormat.GenWithStackByArgs(t))
	}
	return tm, nil
}
func (t MysqlTime) IsLeapYear() bool {
	return (t.year%4 == 0 && t.year%100 != 0) || t.year%400 == 0
}
func calcTimeFromSec(to *MysqlTime, seconds, microseconds int) {
	to.hour = seconds / 3600
	seconds = seconds % 3600
	to.minute = uint8(seconds / 60)
	to.second = uint8(seconds % 60)
	to.microsecond = uint32(microseconds)
}
const secondsIn24Hour = 86400
func calcTimeDiff(t1, t2 MysqlTime, sign int) (seconds, microseconds int, neg bool) {
	days := calcDaynr(t1.Year(), t1.Month(), t1.Day())
	days2 := calcDaynr(t2.Year(), t2.Month(), t2.Day())
	days -= sign * days2
	tmp := (int64(days)*secondsIn24Hour+
		int64(t1.Hour())*3600+int64(t1.Minute())*60+
		int64(t1.Second())-
		int64(sign)*(int64(t2.Hour())*3600+int64(t2.Minute())*60+
			int64(t2.Second())))*
		1e6 +
		int64(t1.Microsecond()) - int64(sign)*int64(t2.Microsecond())
	if tmp < 0 {
		tmp = -tmp
		neg = true
	}
	seconds = int(tmp / 1e6)
	microseconds = int(tmp % 1e6)
	return
}
func datetimeToUint64(t MysqlTime) uint64 {
	return dateToUint64(t)*1e6 + timeToUint64(t)
}