// DateTime produces a random date.
191676
func (r *RandomGenerator) DateTime() time.Time {
	// Use a constant max value to make sure the same pseudo random
	// values get generated for a given API.
	max := time.Date(2016, time.July, 11, 23, 0, 0, 0, time.UTC).Unix()
	unix := r.rand.Int63n(max)
	return time.Unix(unix, 0).UTC()
}
1295480
func ParseDateTime(val string) time.Time {
	t, err := time.Parse(DateTimeFormat, val)
	if err != nil {
		return time.Time{}
	}

	return t
}
715022
func DatetimeToNative(v sqltypes.Value, loc *time.Location) (time.Time, error) {
	// Valid format string offsets for a DATETIME
	//  |DATETIME          |19+
	//  |------------------|------|
	// "2006-01-02 15:04:05.999999"
	return parseISOTime(v.ToString(), loc, 19, isoTimeLength)
}
912104
func DateFor(year int, month time.Month, day int) Date {
	return Date{
		t: time.Date(year, month, day, 0, 0, 0, 0, time.UTC),
	}
}
763914
func Date(ti int64, format string) string {
	t := time.Unix(int64(ti), 0)
	return DateT(t, format)
}
539241
func (dt *DateTime) Gt(value time.Time) *DateTime {
	if !dt.value.After(value) {
		dt.chain.fail("\nexpected datetime > then:\n %s\n\nbut got:\n %s",
			value, dt.value)
	}
	return dt
}
970834
func (c *Carbon) SetDateTime(y int, mon time.Month, d, h, m, s int) {
	c.Time = time.Date(y, mon, d, h, m, s, c.Nanosecond(), c.Location())
}
671279
func (d DateTime) Date(v reflect.Value) (interface{}, error) {
	return d.date(), nil
}
738613
func DateParse(dateString, format string) (time.Time, error) {
	replacer := strings.NewReplacer(datePatterns...)
	format = replacer.Replace(format)
	return time.ParseInLocation(format, dateString, time.Local)
}
334584
func DateParse(dateString, format string) (time.Time, error) {
	return time.ParseInLocation(ConvDateFormat(format), dateString, time.Local)
}
664407
func FormatDateTimeField(key string, val time.Time) (string, string) {
	return key + ";VALUE=DATE-TIME", val.Format("20060102T150405")
}
323907
func getDateTimePattern(datetimePattern, datePattern, timePattern string) string {
	return strings.Replace(strings.Replace(datetimePattern, "{1}", datePattern, 1), "{0}", timePattern, 1)
}
736486
func (dd Date) Time(loc *time.Location) (t time.Time) {
	if !dd.IsZero() {
		t = time.Date(
			int(dd.Year), time.Month(dd.Month), int(dd.Day),
			0, 0, 0, 0,
			loc,
		)
	}
	return
}
479646
func (d date) DateUTC(year, month, day int) time.Time {
	return time.Date(year, time.Month(month), day, 12, 0, 0, 0, time.UTC)
}
999290
func (d date) Time(hour, min, sec, nsec int, loc *time.Location) time.Time {
	return time.Date(0, 0, 0, hour, min, sec, nsec, loc)
}
880911
func toLocalDateTime(t time.Time) DateTime {
	y, m, d := t.Date()
	hour, minute, second := t.Clock()
	return DateTimeFor(y, m, d, hour, minute, second)
}
870134
func FormatDateField(key string, val time.Time) (string, string) {
	return key + ";VALUE=DATE", val.Format("20060102")
}