func (t *DateTime) UnmarshalBinary(data []byte) error {
	var original time.Time
	err := original.UnmarshalBinary(data)
	if err != nil {
		return err
	}
	*t = DateTime(original)
	return nil
}
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
package strfmt
import (
	"database/sql/driver"
	"encoding/binary"
	"encoding/json"
	"fmt"
	"regexp"
	"strings"
	"time"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/bson/bsontype"
)
func init() {
	dt := DateTime{}
	Default.Add("datetime", &dt, IsDateTime)
}
func IsDateTime(str string) bool {
	if len(str) < 4 {
		return false
	}
	s := strings.Split(strings.ToLower(str), "t")
	if len(s) < 2 || !IsDate(s[0]) {
		return false
	}
	matches := rxDateTime.FindAllStringSubmatch(s[1], -1)
	if len(matches) == 0 || len(matches[0]) == 0 {
		return false
	}
	m := matches[0]
	res := m[1] <= "23" && m[2] <= "59" && m[3] <= "59"
	return res
}
const (
	RFC3339Millis = "2006-01-02T15:04:05.000Z07:00"
	RFC3339MillisNoColon = "2006-01-02T15:04:05.000Z0700"
	RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00"
	RFC3339MicroNoColon = "2006-01-02T15:04:05.000000Z0700"
	ISO8601LocalTime = "2006-01-02T15:04:05"
	ISO8601TimeWithReducedPrecision = "2006-01-02T15:04Z"
	ISO8601TimeWithReducedPrecisionLocaltime = "2006-01-02T15:04"
	ISO8601TimeUniversalSortableDateTimePattern = "2006-01-02 15:04:05"
	DateTimePattern = `^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$`
)
var (
	rxDateTime = regexp.MustCompile(DateTimePattern)
	DateTimeFormats = []string{RFC3339Micro, RFC3339MicroNoColon, RFC3339Millis, RFC3339MillisNoColon, time.RFC3339, time.RFC3339Nano, ISO8601LocalTime, ISO8601TimeWithReducedPrecision, ISO8601TimeWithReducedPrecisionLocaltime, ISO8601TimeUniversalSortableDateTimePattern}
	MarshalFormat = RFC3339Millis
	NormalizeTimeForMarshal = func(t time.Time) time.Time { return t }
)
func ParseDateTime(data string) (DateTime, error) {
	if data == "" {
		return NewDateTime(), nil
	}
	var lastError error
	for _, layout := range DateTimeFormats {
		dd, err := time.Parse(layout, data)
		if err != nil {
			lastError = err
			continue
		}
		return DateTime(dd), nil
	}
	return DateTime{}, lastError
}
type DateTime time.Time
func NewDateTime() DateTime {
	return DateTime(time.Unix(0, 0).UTC())
}
func (t DateTime) String() string {
	return NormalizeTimeForMarshal(time.Time(t)).Format(MarshalFormat)
}
func (t DateTime) MarshalText() ([]byte, error) {
	return []byte(t.String()), nil
}
func (t *DateTime) UnmarshalText(text []byte) error {
	tt, err := ParseDateTime(string(text))
	if err != nil {
		return err
	}
	*t = tt
	return nil
}
func (t *DateTime) Scan(raw interface{}) error {
	switch v := raw.(type) {
	case []byte:
		return t.UnmarshalText(v)
	case string:
		return t.UnmarshalText([]byte(v))
	case time.Time:
		*t = DateTime(v)
	case nil:
		*t = DateTime{}
	default:
		return fmt.Errorf("cannot sql.Scan() strfmt.DateTime from: %#v", v)
	}
	return nil
}
func (t DateTime) Value() (driver.Value, error) {
	return driver.Value(t.String()), nil
}
func (t DateTime) MarshalJSON() ([]byte, error) {
	return json.Marshal(NormalizeTimeForMarshal(time.Time(t)).Format(MarshalFormat))
}
func (t *DateTime) UnmarshalJSON(data []byte) error {
	if string(data) == jsonNull {
		return nil
	}
	var tstr string
	if err := json.Unmarshal(data, &tstr); err != nil {
		return err
	}
	tt, err := ParseDateTime(tstr)
	if err != nil {
		return err
	}
	*t = tt
	return nil
}
func (t DateTime) MarshalBSON() ([]byte, error) {
	return bson.Marshal(bson.M{"data": t})
}
func (t *DateTime) UnmarshalBSON(data []byte) error {
	var obj struct {
		Data DateTime
	}
	if err := bson.Unmarshal(data, &obj); err != nil {
		return err
	}
	*t = obj.Data
	return nil
}
func (t DateTime) MarshalBSONValue() (bsontype.Type, []byte, error) {
	i64 := NormalizeTimeForMarshal(time.Time(t)).Unix() * 1000
	buf := make([]byte, 8)
	binary.LittleEndian.PutUint64(buf, uint64(i64))
	return bsontype.DateTime, buf, nil
}
func (t *DateTime) UnmarshalBSONValue(tpe bsontype.Type, data []byte) error {
	i64 := int64(binary.LittleEndian.Uint64(data))
	*t = DateTime(time.Unix(i64/1000, i64%1000*1000000))
	return nil
}
func (t *DateTime) DeepCopyInto(out *DateTime) {
	*out = *t
}
func (t *DateTime) DeepCopy() *DateTime {
	if t == nil {
		return nil
	}
	out := new(DateTime)
	t.DeepCopyInto(out)
	return out
}
func (t DateTime) GobEncode() ([]byte, error) {
	return t.MarshalBinary()
}
func (t *DateTime) GobDecode(data []byte) error {
	return t.UnmarshalBinary(data)
}
func (t DateTime) MarshalBinary() ([]byte, error) {
	return NormalizeTimeForMarshal(time.Time(t)).MarshalBinary()
}