// TIME-SECOND = 2DIGIT  ; 00-59
965510
func parseSecond(buff []byte, cursor *int, l int) (int, error) {
	return syslogparser.Parse2Digits(buff, cursor, l, 0, 59, ErrSecondInvalid)
}
634460
func TimeString(t time.Time) string {
	if t.IsZero() {
		return "0000-00-00 00:00:00"
	}
	if t.Nanosecond() == 0 {
		return t.Format(TimeFormat[:19])
	}
	return t.Format(TimeFormat)
}
11143
func (o Timestamp) Time() time.Time {
	return time.Unix(0, int64((o-gregorianToUNIXOffset)*100)).UTC()
}
1208064
func GreaterTime(t1, t2 time.Time) time.Time {
	if IsGreaterThan(t1, t2, false) {
		return t1
	}
	return t2
}
525164
func printTimestamp(v uint32) *bytes.Buffer {
	if v == 0 {
		return bytes.NewBuffer(ZeroTimestamp)
	}

	t := time.Unix(int64(v), 0).UTC()
	year, month, day := t.Date()
	hour, minute, second := t.Clock()

	result := &bytes.Buffer{}
	fmt.Fprintf(result, "%04d-%02d-%02d %02d:%02d:%02d", year, int(month), day, hour, minute, second)
	return result
}
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()),
	}
}
579182
func (t JSONTime) Time() time.Time {
	t0, err := time.Parse("20060102T150405-0700", string(t))
	if err != nil {
		return time.Time{}
	}
	return t0
}
977341
func (tt Timetag) Time() time.Time {
	secs := (uint64(tt) >> 32) - SecondsFrom1900To1970
	return time.Unix(int64(secs), int64(tt)&0xFFFFFFFF).UTC()
}
106859
func timeParser(rd *proto.Reader, n int64) (interface{}, error) {
	if n != 2 {
		return nil, fmt.Errorf("got %d elements, expected 2", n)
	}

	sec, err := rd.ReadInt()
	if err != nil {
		return nil, err
	}

	microsec, err := rd.ReadInt()
	if err != nil {
		return nil, err
	}

	return time.Unix(sec, microsec*1000), nil
}
399517
func timeToUint64(t TimeInternal) uint64 {
	return uint64(uint64(t.Hour())*10000 +
		uint64(t.Minute())*100 +
		uint64(t.Second()))
}
494928
func timePseudoTypeEncoder(v reflect.Value) (interface{}, error) {
	t := v.Interface().(time.Time)

	timeVal := float64(t.UnixNano()) / float64(time.Second)

	// use seconds-since-epoch precision if time.Time `t`
	// is before the oldest nanosecond time
	if t.Before(time.Unix(0, math.MinInt64)) {
		timeVal = float64(t.Unix())
	}

	return map[string]interface{}{
		"$reql_type$": "TIME",
		"epoch_time":  timeVal,
		"timezone":    t.Format("-07:00"),
	}, nil
}
98358
func timeToEpochMilliseconds(t time.Time) int64 {
	return t.UnixNano() / int64(time.Millisecond)
}
722587
func Time() gopter.Gen {
	return func(genParams *gopter.GenParameters) *gopter.GenResult {
		sec := genParams.Rng.Int63n(253402214400) // Ensure year in [0, 9999]
		usec := genParams.Rng.Int63n(1000000000)

		return gopter.NewGenResult(time.Unix(sec, usec), TimeShrinker)
	}
}
1066748
func (t *Timings) Time() int64 {
	t.mu.Lock()
	defer t.mu.Unlock()
	return t.totalTime
}
774340
func TimestampToTime(timestamp *timestamp.Timestamp) time.Time {
	if timestamp == nil {
		return time.Unix(0, 0).UTC()
	}
	return time.Unix(
		timestamp.Seconds,
		int64(timestamp.Nanos),
	).UTC()
}
1353198
func timeToMsDosTime(t time.Time) (fDate uint16, fTime uint16) {
	t = t.In(time.UTC)
	fDate = uint16(t.Day() + int(t.Month())<<5 + (t.Year()-1980)<<9)
	fTime = uint16(t.Second()/2 + t.Minute()<<5 + t.Hour()<<11)
	return
}
1256463
func (t Time) String() string {
	return strconv.FormatFloat(float64(t)/float64(second), 'f', -1, 64)
}