// Seconds returns the seconds in a time object as a number between 0 and
// 59.999 (double precision).
484272
func (t Term) Seconds(args ...interface{}) Term {
	return constructMethodTerm(t, "Seconds", p.Term_SECONDS, args, map[string]interface{}{})
}
402501
func (t *Timer) Time(f func()) {
	s := time.Now()
	f()
	t.UpdateSince(s)
}
153161
func (j *Job) Duration() time.Duration {
	if j.Finished().IsZero() {
		return 0 * time.Second
	}
	return j.Finished().Sub(j.Started())
}
1303971
func (c *Client) Expire(key string, seconds int) (bool, error) {
	v, err := c.execWithKey(true, "EXPIRE", key, seconds)
	if err != nil {
		return false, err
	}
	return iface2bool(v)
}
603194
func (t TimeSinceEpoch) Time() time.Time {
	ts := float64(t) / 1
	secs := int64(ts)
	nsecs := int64((ts - float64(secs)) * 1000000000)
	return time.Unix(secs, nsecs)
}
544805
func (d *TimePeriod_Duration) ToSeconds() (int64, error) {
	// Decompose the duration into a slice of [duration, <int64>, <unit>].
	m := regexp.MustCompile(durationRegex).FindStringSubmatch(d.Duration)
	if len(m) != 3 {
		return 0, errors.Reason("duration must match regex %q", durationRegex).Err()
	}
	n, err := strconv.ParseInt(m[1], 10, 64)
	if err != nil {
		return 0, errors.Reason("duration must not exceed %q", int64(math.MaxInt64)).Err()
	}
	var mul int64
	switch m[2] {
	case "s":
		// 1 second.
		mul = 1
	case "m":
		// 60 seconds.
		mul = 60
	case "h":
		// 60 minutes.
		mul = 3600
	case "d":
		// 24 hours.
		mul = 86400
	case "mo":
		// 30 days.
		mul = 2592000
	}
	if n > math.MaxInt64/mul {
		n = math.MaxInt64
	} else {
		n *= mul
	}
	return n, nil
}
354636
func Min(real []float64, timePeriod int32) []float64 {
	var outBegIdx C.int
	var outNBElement C.int
	outReal := make([]float64, len(real))
	C.TA_MIN(0, C.int(len(real)-1), (*C.double)(unsafe.Pointer(&real[0])), C.int(timePeriod), &outBegIdx, &outNBElement, (*C.double)(unsafe.Pointer(&outReal[0])))
	return outReal[:outNBElement]
}
348710
func (f *Frame) Duration() time.Duration {
	if !f.Header.IsValid() {
		return 0
	}
	ms := (1000 / float64(f.Header.SampleRate())) * float64(f.Header.Samples())
	dur := time.Duration(int(float64(time.Millisecond) * ms))
	if dur < 0 {
		// we have bad data, let's ignore it
		dur = 0
	}
	return dur
}
1156355
func (dec *Decoder) Time(v *time.Time, format string) error {
	err := dec.decodeTime(v, format)
	if err != nil {
		return err
	}
	dec.called |= 1
	return nil
}
866268
func (d Duration) Minute() int {
	_, _, minute, _, _ := splitDuration(d.Duration)
	return minute
}
795857
func (e PrecisionTiming) durationToMs(x time.Duration) float64 {
	return float64(x) / float64(time.Millisecond)
}
1077959
func (c *Carbon) SecondsUntilEndOfDay() int {
	dayEnd := c.EndOfDay()

	return int(c.DiffInSeconds(dayEnd, true))
}
654342
func (j *Job) Minute() (job *Job) {
	if j.interval != 1 {
		panic("")
	}
	job = j.Minutes()
	return
}
1308685
func DurationStrToSecondsInt(s string) *int {
	if s == "" {
		return nil
	}
	duration, err := time.ParseDuration(s)
	if err != nil {
		logrus.Errorf("Failed to parse duration:%v", s)
		return nil
	}
	r := (int)(duration.Seconds())
	return &r

}
1251003
func SecondInList(t time.Time, seconds []int) bool {
	for _, second := range seconds {
		if t.Second() == second {
			return true
		}
	}
	return false
}
87192
func (t Time) ConvertToDuration() (Duration, error) {
	if t.IsZero() {
		return ZeroDuration, nil
	}

	hour, minute, second := t.Clock()
	frac := t.Time.Microsecond() * 1000

	d := gotime.Duration(hour*3600+minute*60+second)*gotime.Second + gotime.Duration(frac)
	// TODO: check convert validation
	return Duration{Duration: d, Fsp: t.Fsp}, nil
}
87740
func MillisecondsSince(t time.Time) int {
	return int(time.Since(t) / time.Millisecond)
}