// See https://github.com/golang/go/blob/f06795d9b742cf3292a0f254646c23603fc6419b/src/time/format.go#L9-L41
511757
func (v vars) Now(layout string) string {
	return time.Now().Format(layout)
}
1098223
func FormatDateTime(key string, val time.Time) (string, string) {
	return key, val.UTC().Format("20060102T150405Z")
}
1054586
func (r *Redis) Time() ([]string, error) {
	rp, err := r.ExecuteCommand("TIME")
	if err != nil {
		return nil, err
	}
	return rp.ListValue()
}
29488
func (d DateTime) Time(v reflect.Value) (interface{}, error) {
	return d.time(), nil
}
827443
func getTime(v interface{}) time.Time {
	sval, ok := v.(string)
	if !ok {
		return time.Time{}
	}
	t, err := time.Parse(time.RFC3339, sval)
	if err != nil {
		return time.Time{}
	}
	return t
}
199270
func FormatTime(t *time.Time, formatISO bool) string {
	if formatISO {
		// If requested, use ISO time format.
		// The format we use is RFC3339 without the "T". From the spec:
		// NOTE: ISO 8601 defines date and time separated by "T".
		// Applications using this syntax may choose, for the sake of
		// readability, to specify a full-date and full-time separated by
		// (say) a space character.
		return t.UTC().Format("2006-01-02 15:04:05Z")
	}
	// Otherwise use local time.
	return t.Local().Format("02 Jan 2006 15:04:05Z07:00")
}
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
}
98532
func (timeCache *timeFormatCacheType) Format() []byte {
	timeCache.lock.RLock()
	defer timeCache.lock.RUnlock()

	return timeCache.format
}
1011560
func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte {
	switch format {
	case timeFormatUnix:
		return e.AppendInt64(dst, t.Unix())
	case timeFormatUnixMs:
		return e.AppendInt64(dst, t.UnixNano()/1000000)
	}
	return append(t.AppendFormat(append(dst, '"'), format), '"')
}
1251696
func (k *Key) Time() (time.Time, error) {
	return k.TimeFormat(time.RFC3339)
}
1062355
func Time(val interface{}) time.Time {
	switch t := val.(type) {
	// We could use this later.
	default:
		s := String(t)
		for _, format := range strToTimeFormats {
			r, err := time.ParseInLocation(format, s, time.Local)
			if err == nil {
				return r
			}
		}
	}
	return time.Time{}
}
75214
func (d Date) Format(layout string) string {
	return d.t.Format(layout)
}
940552
func Strftime(t *time.Time, f string) string {
	var result []string
	format := []rune(f)

	add := func(str string) {
		result = append(result, str)
	}

	for i := 0; i < len(format); i++ {
		switch format[i] {
		case '%':
			if i < len(format)-1 {
				switch format[i+1] {
				case 'a':
					add(shortDayNames[t.Weekday()])
				case 'A':
					add(longDayNames[t.Weekday()])
				case 'w':
					add(fmt.Sprintf("%d", t.Weekday()))
				case 'd':
					add(fmt.Sprintf("%02d", t.Day()))
				case 'b':
					add(shortMonthNames[t.Month()])
				case 'B':
					add(longMonthNames[t.Month()])
				case 'm':
					add(fmt.Sprintf("%02d", t.Month()))
				case 'y':
					add(fmt.Sprintf("%02d", t.Year()%100))
				case 'Y':
					add(fmt.Sprintf("%02d", t.Year()))
				case 'H':
					add(fmt.Sprintf("%02d", t.Hour()))
				case 'I':
					if t.Hour() == 0 {
						add(fmt.Sprintf("%02d", 12))
					} else if t.Hour() > 12 {
						add(fmt.Sprintf("%02d", t.Hour()-12))
					} else {
						add(fmt.Sprintf("%02d", t.Hour()))
					}
				case 'p':
					if t.Hour() < 12 {
						add("AM")
					} else {
						add("PM")
					}
				case 'M':
					add(fmt.Sprintf("%02d", t.Minute()))
				case 'S':
					add(fmt.Sprintf("%02d", t.Second()))
				case 'f':
					add(fmt.Sprintf("%06d", t.Nanosecond()/1000))
				case 'z':
					add(t.Format("-0700"))
				case 'Z':
					add(t.Format("MST"))
				case 'j':
					add(fmt.Sprintf("%03d", t.YearDay()))
				case 'U':
					add(fmt.Sprintf("%02d", weekNumber(t, 'U')))
				case 'W':
					add(fmt.Sprintf("%02d", weekNumber(t, 'W')))
				case 'c':
					add(t.Format("Mon Jan 2 15:04:05 2006"))
				case 'x':
					add(fmt.Sprintf("%02d/%02d/%02d", t.Month(), t.Day(), t.Year()%100))
				case 'X':
					add(fmt.Sprintf("%02d:%02d:%02d", t.Hour(), t.Minute(), t.Second()))
				case '%':
					add("%")
				}
				i += 1
			}
		default:
			add(string(format[i]))
		}
	}

	return strings.Join(result, "")
}
957847
func (b *Builder) Time(ts time.Time) *Builder {
	b.TimeSec = uint64(ts.Unix())
	b.TimeNsec = uint32(ts.Nanosecond())
	return b
}
109654
func (enc *Encoder) encodeTime(t *time.Time, format string) ([]byte, error) {
	enc.writeByte('"')
	enc.buf = t.AppendFormat(enc.buf, format)
	enc.writeByte('"')
	return enc.buf, nil
}
376663
func (enc *Encoder) Time(t *time.Time, format string) {
	enc.grow(10)
	r := enc.getPreviousRune()
	if r != '[' {
		enc.writeByte(',')
	}
	enc.writeByte('"')
	enc.buf = t.AppendFormat(enc.buf, format)
	enc.writeByte('"')
}
1257733
func (e Error) Format(a ...interface{}) Error {
	e.message = fmt.Sprintf(e.message, a...)
	return e
}