// StopAt reports the time difference between now and the time the clock was created at.
//
// The metric produced by this method call will have a "stamp" tag set to
// "total".
552915
func (c *Clock) StopAt(now time.Time) {
	c.observe("total", now.Sub(c.first))
}
601184
func (t Term) DeleteAt(args ...interface{}) Term {
	return constructMethodTerm(t, "DeleteAt", p.Term_DELETE_AT, args, map[string]interface{}{})
}
1348243
func (w *WindowedSchedule) setStopOnTime() {
	if w.StopTime == nil && w.Count != 0 {
		// determine the window stop based on the `count` and `interval`
		var newStop time.Time

		// if start is not set or points in the past,
		// use the current time to calculate stopOnTime
		if w.StartTime != nil && time.Now().Before(*w.StartTime) {
			newStop = w.StartTime.Add(time.Duration(w.Count) * w.Interval)
		} else {
			// set a new stop timestamp from this point in time
			newStop = time.Now().Add(time.Duration(w.Count) * w.Interval)
		}
		// set calculated new stop
		w.stopOnTime = &newStop
		return
	}

	// stopOnTime is determined by StopTime
	w.stopOnTime = w.StopTime
}
1338445
func (s *ContinuousExportDescription) SetStopTime(v time.Time) *ContinuousExportDescription {
	s.StopTime = &v
	return s
}
35904
func (s *States) setStateAt(state int64, now time.Time) {
	if state < 0 || state >= int64(len(s.labels)) {
		panic(fmt.Errorf("State out of range 0-%v: %v", len(s.labels), state))
	}

	s.mu.Lock()
	defer s.mu.Unlock()

	// check we're going strictly forward in time
	dur := now.Sub(s.since)
	if dur < 0 {
		panic(fmt.Errorf("Time going backwards? %v < %v", now, s.since))
	}

	// record the previous state duration, reset our state
	s.durations[s.state] += dur
	s.transitions[state] += 1
	s.state = state
	s.since = now
}
1013029
func (c *CheckRun) GetStartedAt() Timestamp {
	if c == nil || c.StartedAt == nil {
		return Timestamp{}
	}
	return *c.StartedAt
}
726950
func (m *Metrics) Stop(timer *MetricTimer) {
	if timer != nil {
		timer.Timer.UpdateSince(timer.Time)
	}
}
990782
func (m *Milestone) GetCreatedAt() time.Time {
	if m == nil || m.CreatedAt == nil {
		return time.Time{}
	}
	return *m.CreatedAt
}
27397
func (t *TeamDiscussion) GetCreatedAt() Timestamp {
	if t == nil || t.CreatedAt == nil {
		return Timestamp{}
	}
	return *t.CreatedAt
}
818669
func TimeDifference(server string) (time.Duration, error) {
	output, err := exec.Command("/usr/sbin/ntpdate", "-q", server).CombinedOutput()
	if err != nil {
		return time.Duration(0), err
	}

	re, _ := regexp.Compile("offset (.*) sec")
	submatched := re.FindSubmatch(output)
	if len(submatched) != 2 {
		return time.Duration(0), errors.New("invalid ntpdate output")
	}

	f, err := strconv.ParseFloat(string(submatched[1]), 64)
	if err != nil {
		return time.Duration(0), err
	}
	return time.Duration(f*1000) * time.Millisecond, nil
}
877868
func (s *Evaluation) SetFinishedAt(v time.Time) *Evaluation {
	s.FinishedAt = &v
	return s
}
712235
func (l *List) CreatedAt() time.Time {
	t, _ := IDToTime(l.ID)
	return t
}
244953
func (s *AttemptDetail) SetStoppedAt(v int64) *AttemptDetail {
	s.StoppedAt = &v
	return s
}
177020
func (d *DeploymentStatus) GetCreatedAt() Timestamp {
	if d == nil || d.CreatedAt == nil {
		return Timestamp{}
	}
	return *d.CreatedAt
}
778368
func (at *AccessToken) IsExpiredAt(testtime time.Time) bool {
	return testtime.After(at.ExpirationTime())
}
122579
func (d *Deployment) GetCreatedAt() Timestamp {
	if d == nil || d.CreatedAt == nil {
		return Timestamp{}
	}
	return *d.CreatedAt
}
28025
func ValidAt(t time.Time) Validator {
	return func(token *JSONToken) error {
		if !token.IssuedAt.IsZero() && t.Before(token.IssuedAt) {
			return errors.Wrapf(ErrTokenValidationError, "token was issued in the future")
		}
		if !token.NotBefore.IsZero() && t.Before(token.NotBefore) {
			return errors.Wrapf(ErrTokenValidationError, "token cannot be used yet")
		}
		if !token.Expiration.IsZero() && t.After(token.Expiration) {
			return errors.Wrapf(ErrTokenValidationError, "token has expired")
		}
		return nil
	}
}