// MicroToTime converts zipkin's native time of microseconds into time.Time
180454
func MicroToTime(micro int64) time.Time {
	return time.Unix(0, micro*int64(time.Microsecond)).UTC()
}
729732
func ProtoToTime(ts *logutilpb.Time) time.Time {
	if ts == nil {
		// treat nil like the empty Timestamp
		return time.Unix(0, 0).UTC()
	}
	return time.Unix(ts.Seconds, int64(ts.Nanoseconds)).UTC()
}
418105
func ToNormalizedTime(t time.Time, u time.Duration) int64 {
	return t.UnixNano() / u.Nanoseconds()
}
689656
func Convert_v1_Time_To_v1_Time(in *Time, out *Time, s conversion.Scope) error {
	// Cannot deep copy these, because time.Time has unexported fields.
	*out = *in
	return nil
}
25662
func (t *TimeOfDay) toTime() (time.Time, error) {
	now := time.Time{}
	loc, err := time.LoadLocation(t.GetLocation())
	if err != nil {
		return now, errors.Reason("invalid location").Err()
	}
	now = now.In(loc)
	// Decompose the time into a slice of [time, <hour>, <minute>].
	m := regexp.MustCompile(timeRegex).FindStringSubmatch(t.GetTime())
	if len(m) != 3 {
		return now, errors.Reason("time must match regex %q", timeRegex).Err()
	}
	hr, err := strconv.Atoi(m[1])
	if err != nil || hr > 23 {
		return now, errors.Reason("time must not exceed 23:xx").Err()
	}
	min, err := strconv.Atoi(m[2])
	if err != nil || min > 59 {
		return now, errors.Reason("time must not exceed xx:59").Err()
	}
	return time.Date(now.Year(), now.Month(), now.Day(), hr, min, 0, 0, loc), nil
}
1226562
func (d Duration) ConvertToTime(sc *stmtctx.StatementContext, tp uint8) (Time, error) {
	year, month, day := gotime.Now().In(sc.TimeZone).Date()
	sign, hour, minute, second, frac := splitDuration(d.Duration)
	datePart := FromDate(year, int(month), day, 0, 0, 0, 0)
	timePart := FromDate(0, 0, 0, hour, minute, second, frac)
	mixDateAndTime(&datePart, &timePart, sign < 0)

	t := Time{
		Time: datePart,
		Type: mysql.TypeDatetime,
		Fsp:  d.Fsp,
	}
	return t.Convert(sc, tp)
}
494585
func (e *ephemeralGitConfigWithFixedPackWindow) LooseObjectTime(
	h plumbing.Hash) (time.Time, error) {
	return e.los.LooseObjectTime(h)
}
662539
func (timestamp *Timestamp) Time() time.Time {
	return time.Date(timestamp.Year, time.Month(timestamp.Month), timestamp.Day,
		timestamp.Hour, timestamp.Min, timestamp.Sec, timestamp.NanoSec, time.UTC)
}
1138063
func reqlTimeToNativeTime(timestamp float64, timezone string) (time.Time, error) {
	sec, ms := math.Modf(timestamp)

	// Convert to native time rounding to milliseconds
	t := time.Unix(int64(sec), int64(math.Floor(ms*1000+0.5))*1000*1000)

	// Caclulate the timezone
	if timezone != "" {
		hours, err := strconv.Atoi(timezone[1:3])
		if err != nil {
			return time.Time{}, err
		}
		minutes, err := strconv.Atoi(timezone[4:6])
		if err != nil {
			return time.Time{}, err
		}
		tzOffset := ((hours * 60) + minutes) * 60
		if timezone[:1] == "-" {
			tzOffset = 0 - tzOffset
		}

		t = t.In(time.FixedZone(timezone, tzOffset))
	}

	return t, nil
}
1040286
func (f *TimeFuncs) Microsecond(n interface{}) gotime.Duration {
	return gotime.Microsecond * gotime.Duration(conv.ToInt64(n))
}
1139675
func (c *Client) TimeInMilliseconds(name string, value float64, tags []string, rate float64) error {
	return c.send(name, value, timingSuffix, tags, rate)
}
940100
func (t MicroTime) MarshalJSON() ([]byte, error) {
	if t.IsZero() {
		// Encode unset/nil objects as JSON's "null".
		return []byte("null"), nil
	}

	return json.Marshal(t.UTC().Format(RFC3339Micro))
}
579182
func (t JSONTime) Time() time.Time {
	t0, err := time.Parse("20060102T150405-0700", string(t))
	if err != nil {
		return time.Time{}
	}
	return t0
}
1166166
func (a *Array) Time(t time.Time) *Array {
	a.buf = enc.AppendTime(enc.AppendArrayDelim(a.buf), t, TimeFieldFormat)
	return a
}
1105944
func TimeFromProto(t *timestamp.Timestamp) time.Time {
	if t == nil {
		return time.Time{}
	}
	return time.Unix(t.Seconds, int64(t.Nanos)).UTC()
}
741923
func (m *Time) ProtoTime() *Timestamp {
	if m == nil {
		return &Timestamp{}
	}
	return &Timestamp{
		Seconds: m.Time.Unix(),
		// leaving this here for the record.  our JSON only handled seconds, so this results in writes by
		// protobuf clients storing values that aren't read by json clients, which results in unexpected
		// field mutation, which fails various validation and equality code.
		// Nanos:   int32(m.Time.Nanosecond()),
	}
}
1316227
func (d Duration) ConvertToTime(tp uint8) (Time, error) {
	year, month, day := gotime.Now().Date()
	// just use current year, month and day.
	n := gotime.Date(year, month, day, 0, 0, 0, 0, gotime.Local)
	n = n.Add(d.Duration)

	t := Time{
		Time: FromGoTime(n),
		Type: mysql.TypeDatetime,
		Fsp:  d.Fsp,
	}

	return t.Convert(tp)
}