func (t *Date) Scan(v interface{}) error {
	value, ok := v.(time.Time)
	if ok {
		*t = DateByTime(value)
		return nil
	}
	return fmt.Errorf("can not convert %v to Date", v)
}
Scan support scan
package bast
import (
	"database/sql/driver"
	"errors"
	"fmt"
	"strings"
	"time"
)
var loc *time.Location
func init() {
	loc, _ = time.LoadLocation("Local")
}
type Time struct {
	time.Time
}
func (t Time) MarshalJSON() ([]byte, error) {
	stamp := "\"\""
	if !t.IsZero() {
		stamp = fmt.Sprintf("\"%s\"", t.Time.Format("2006-01-02 15:04:05"))
	}
	return []byte(stamp), nil
}
func (t *Time) UnmarshalJSON(b []byte) error {
	tt, err := byteToTime(b, "")
	if err == nil {
		*t = tt
	}
	return err
}
func (t Time) Value() (driver.Value, error) {
	var zeroTime time.Time
	if t.Time.UnixNano() == zeroTime.UnixNano() {
		return nil, nil
	}
	return t.Time, nil
}
func (t *Time) Scan(v interface{}) error {
	value, ok := v.(time.Time)
	if ok {
		*t = Time{Time: value}
		return nil
	}
	return fmt.Errorf("can not convert %v to Time", v)
}
func (t *Time) T() *time.Time {
	if !t.IsZero() {
		return &t.Time
	}
	return nil
}
func Now() Time {
	tt := Time{Time: time.Now()}
	return tt
}
func Nows() *Time {
	tt := Time{Time: time.Now()}
	return &tt
}
func NowsNil() *Time {
	var t Time
	return &t
}
func NowTime() *Time {
	tt := Time{Time: time.Now()}
	return &tt
}
func TimeByTime(t time.Time) Time {
	tt := Time{Time: t}
	return Time(tt)
}
func TimesByTime(t time.Time) *Time {
	tt := TimeByTime(t)
	return &tt
}
func TimeByDate(d Date) Time {
	t := Time(d)
	return t
}
func TimeByDates(d *Date) Time {
	var t Time
	if d != nil {
		t = Time(*d)
	}
	return t
}
func TimesByDate(d Date) *Time {
	tt := Time(d)
	return &tt
}
func TimesByDates(d *Date) *Time {
	if d != nil {
		t := Time(*d)
		return &t
	}
	return nil
}
func TimeWithString(t string, layout ...string) (Time, error) {
	l := ""
	if layout != nil {
		l = layout[0]
	}
	return strToTime(t, l)
}
func TimesWithString(t string, layout ...string) (*Time, error) {
	l := ""
	if layout != nil {
		l = layout[0]
	}
	tt, err := strToTime(t, l)
	if err == nil {
		t := Time(tt)
		return &t, nil
	}
	return nil, err
}
func strToTime(t string, layout string) (Time, error) {
	return byteToTime([]byte(t), layout)
}
func byteToTime(b []byte, layout string) (Time, error) {
	var t Time
	var err error
	if b != nil && len(b) > 0 {
		s := strings.Trim(string(b), "\"")
		l := len(s)
		var v time.Time
		if l > 0 {
			if layout == "" {
				if l <= 8 {
					layout = "2006-1-2"
				} else if l <= 10 {
					layout = "2006-01-02"
				} else if l <= 16 {
					layout = "2006-01-02 15:04"
				} else {
					layout = "2006-01-02 15:04:05"
				}
			}
			v, err = time.ParseInLocation(layout, s, loc)
			if err == nil {
				t = Time{Time: v}
			} else {
				err = errors.New("bytes to time error")
			}
		}
	}
	return t, err
}
func (t Time) String() string {
	return t.Time.Format("2006-01-02 15:04:05")
}
func (t Time) Format(layout string) string {
	if layout == "" {
		layout = "2006-01-02"
	} else {
		layout = strings.Replace(layout, "yyyy", "2006", 1)
		layout = strings.Replace(layout, "MM", "01", 1)
		layout = strings.Replace(layout, "dd", "02", 1)
		layout = strings.Replace(layout, "hh", "15", 1)
		layout = strings.Replace(layout, "mm", "04", 1)
		layout = strings.Replace(layout, "ss", "05", 1)
	}
	return t.Time.Format(layout)
}
func (t Time) After(u Time) bool {
	return t.Time.After(u.Time)
}
func (t Time) Before(u Time) bool {
	return t.Time.Before(u.Time)
}
func (t Time) Equal(u Time) bool {
	return t.Time.Equal(u.Time)
}
type Date Time
func NowDate() Date {
	y, m, d := time.Now().Date()
	t := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
	return Date(Time{Time: t})
}
func NowDates() *Date {
	d := NowDate()
	return &d
}
func DateByTime(t time.Time) Date {
	y, m, d := t.Date()
	t = time.Date(y, m, d, 0, 0, 0, 0, t.Location())
	return Date(Time{Time: t})
}
func DatesByTime(t time.Time) *Date {
	tt := DateByTime(t)
	return &tt
}
func DateByBTime(t Time) Date {
	return DateByTime(t.Time)
}
func DatesByBTime(t Time) *Date {
	return DatesByTime(t.Time)
}
func DateByBTimes(t *Time) Date {
	var tt Date
	if t != nil {
		tt = DateByTime(t.Time)
	}
	return tt
}
func DatesByBTimes(t *Time) *Date {
	if t != nil {
		return DatesByBTime(*t)
	}
	return nil
}
func DateWithString(t string, layout ...string) (Date, error) {
	l := ""
	if layout != nil {
		l = layout[0]
	}
	tt, err := strToTime(t, l)
	return Date(tt), err
}
func DatesWithString(t string, layout ...string) (*Date, error) {
	l := ""
	if layout != nil {
		l = layout[0]
	}
	tt, err := strToTime(t, l)
	if err == nil {
		d := Date(tt)
		return &d, nil
	}
	return nil, err
}
func (t Date) After(u Date) bool {
	return t.Time.After(u.Time)
}
func (t Date) Before(u Date) bool {
	return t.Time.Before(u.Time)
}
func (t Date) Equal(u Date) bool {
	return t.Time.Equal(u.Time)
}
func (t Date) MarshalJSON() ([]byte, error) {
	stamp := "\"\""
	if !t.IsZero() {
		stamp = fmt.Sprintf("\"%s\"", t.Time.Format("2006-01-02"))
	}
	return []byte(stamp), nil
}
func (t *Date) UnmarshalJSON(b []byte) error {
	if t != nil {
		tt := Time(*t)
		if err := tt.UnmarshalJSON(b); err == nil {
			*t = Date(tt)
		}
	}
	return nil
}
func (t Date) Value() (driver.Value, error) {
	var zt time.Time
	if t.Time.UnixNano() == zt.UnixNano() {
		return nil, nil
	}
	return t.Time, nil
}