// ParseTime exports for testing.
183418
func ParseTime(s string) (time.Time, error) {
	t, err := time.Parse(logutil.SlowLogTimeFormat, s)
	if err != nil {
		// This is for compatibility.
		t, err = time.Parse(logutil.OldSlowLogTimeFormat, s)
		if err != nil {
			err = errors.Errorf("string \"%v\" doesn't has a prefix that matches format \"%v\", err: %v", s, logutil.SlowLogTimeFormat, err)
		}
	}
	return t, err
}
597160
func ParseTime(header http.Header, key string) time.Time {
	if s := header.Get(key); s != "" {
		for _, layout := range timeLayouts {
			if t, err := time.Parse(layout, s); err == nil {
				return t.UTC()
			}
		}
	}
	return time.Time{}
}
89105
func parseTimestamp(filename string) (timestamp time.Time, err error) {
	parts := strings.Split(filepath.Base(filename), ".")
	if len(parts) < 6 {
		return time.Time{}, fmt.Errorf("malformed logfile name: %v", filename)
	}
	return time.ParseInLocation("20060102-150405", parts[len(parts)-2], time.Now().Location())

}
376079
func StrToDateTime(sc *stmtctx.StatementContext, str string, fsp int) (Time, error) {
	return ParseTime(sc, str, mysql.TypeDatetime, fsp)
}
24963
func ParseUptime(uptime string) time.Duration {
	var w, d, h, m, s int
	if uptime == "never" || uptime == "<error>" {
		return 0
	} else if um := uptimeHourRE.FindStringSubmatch(uptime); um != nil {
		h, _ = strconv.Atoi(um[1])
		m, _ = strconv.Atoi(um[2])
		s, _ = strconv.Atoi(um[3])
	} else if um := uptimeDayRE.FindStringSubmatch(uptime); um != nil {
		d, _ = strconv.Atoi(um[1])
		h, _ = strconv.Atoi(um[2])
		m, _ = strconv.Atoi(um[3])
	} else if um := uptimeWeekRE.FindStringSubmatch(uptime); um != nil {
		w, _ = strconv.Atoi(um[1])
		d, _ = strconv.Atoi(um[2])
		h, _ = strconv.Atoi(um[3])
	} else {
		return 0
	}
	return time.Duration(w)*168*time.Hour + time.Duration(d)*24*time.Hour +
		time.Duration(h)*time.Hour + time.Duration(m)*time.Minute +
		time.Duration(s)*time.Second
}
677168
func (self *Commands) IsTime(value interface{}) error {
	if stringutil.IsTime(value) {
		return nil
	} else {
		return fmt.Errorf("Expected time value")
	}
}
246166
func ParseDate(data string) (*time.Time, error) {
	t, err := time.Parse(DateLongFormat, data)
	if err == nil {
		return &t, nil
	}

	t, err = time.Parse(time.RFC3339, data)
	if err == nil {
		return &t, nil
	}

	t, err = time.Parse(DateShortFormat, data)
	if err == nil {
		return &t, nil
	}

	t, err = time.Parse(DateNumberFormat, data)
	if err == nil {
		return &t, nil
	}

	return nil, fmt.Errorf("not a date")
}
82831
func ParseDatetime(str string) (Time, error) {
	return ParseTime(str, mysql.TypeDatetime, DefaultFsp)
}
41286
func (s *QueryFilter) SetDeltaTime(v *DeltaTime) *QueryFilter {
	s.DeltaTime = v
	return s
}
331787
func goTime(t C.pn_timestamp_t) time.Time {
	if t == 0 {
		return time.Time{}
	}
	return time.Unix(0, int64(t)*int64(time.Millisecond))
}
31634
func ParseDate(sc *stmtctx.StatementContext, str string) (Time, error) {
	// date has no fractional seconds precision
	return ParseTime(sc, str, mysql.TypeDate, MinFsp)
}
927607
func parseMessageDateTime(maybeDate string) (time.Time, error) {
	for _, layout := range envelopeDateTimeLayouts {
		parsed, err := time.Parse(layout, maybeDate)
		if err == nil {
			return parsed, nil
		}
	}
	return time.Time{}, fmt.Errorf("date %s could not be parsed", maybeDate)
}
1140321
func parseTime(t interface{}) (time.Time, error) {
	var err error
	var calcTime time.Time
	switch v := t.(type) {
	case string:
		if calcTime, err = time.Parse(TimeFormat, v); err != nil {
			return time.Time{}, errors.New("cannot parse string time")
		}
	case int64:
		calcTime = time.Unix(v, 0).UTC()
	default:
		return time.Time{}, errors.New("arg must be a timestamp")
	}
	return calcTime, nil
}
1295480
func ParseDateTime(val string) time.Time {
	t, err := time.Parse(DateTimeFormat, val)
	if err != nil {
		return time.Time{}
	}

	return t
}
350871
func (b *builtinTimestampLiteralSig) evalTime(row chunk.Row) (types.Time, bool, error) {
	return b.tm, false, nil
}
169834
func isTime(v interface{}) bool {
	s, ok := v.(string)
	if !ok {
		return false
	}
	if _, err := time.Parse("15:04:05Z07:00", s); err == nil {
		return true
	}
	if _, err := time.Parse("15:04:05.999999999Z07:00", s); err == nil {
		return true
	}
	return false
}
848120
func (h *Timing) ServerResponseTime(serverResponseTime int64) *Timing {
	h.serverResponseTime = serverResponseTime
	h.serverResponseTimeSet = true
	return h
}