// Return an array of Arrow's from this one up to the given one,
// by duration.  For instance, Now().UpTo(Tomorrow(), Hour)
// will return an array of Arrow's from now until tomorrow by
// hour (inclusive of a and b).
425364
func (a Arrow) UpTo(b Arrow, by time.Duration) []Arrow {
	var result []Arrow
	if a.After(b) {
		a, b = b, a
	}
	for a.Before(b) || a.Equal(b) {
		result = append(result, a)
		a = a.Add(by)
	}
	return result
}
930619
func (b byTime) Less(i, j int) bool {

	if b[i].Next.IsZero() {
		return false
	}
	if b[j].Next.IsZero() {
		return true
	}

	return b[i].Next.Before(b[j].Next)
}
1175045
func Fibonacci(factor time.Duration) Algorithm {
	return func(attempt uint) time.Duration {
		return (factor * time.Duration(fibonacciNumber(attempt)))
	}
}
315856
func (c *ARC) GetALL() map[interface{}]interface{} {
	m := make(map[interface{}]interface{})
	for _, k := range c.keys() {
		v, err := c.GetIFPresent(k)
		if err == nil {
			m[k] = v
		}
	}
	return m
}
1281076
func ToDuration(ms time.Time) time.Duration {
	return Elapsed(ms, time.Now())
}
1197236
func Duration(max time.Duration) time.Duration {
	nbNanoseconds := 1 + int(rand.Int63n(max.Nanoseconds()))
	return time.Duration(nbNanoseconds) * time.Nanosecond
}
355254
func (time *Timeline) Get() *FeedMedia {
	insta := time.inst
	media := &FeedMedia{}
	media.inst = insta
	media.endpoint = urlTimeline
	return media
}
260617
func _() {
	var _ Event = (*Absolute)(nil)        // assert *Absolute implements Event
	var _ Event = (*FAbsolute)(nil)       // assert *FAbsolute implements Event
	var _ Event = (*Gauge)(nil)           // assert *Gauge implements Event
	var _ Event = (*FGauge)(nil)          // assert *FGauge implements Event
	var _ Event = (*GaugeDelta)(nil)      // assert *GaugeDelta implements Event
	var _ Event = (*FGaugeDelta)(nil)     // assert *FGaugeDelta implements Event
	var _ Event = (*Increment)(nil)       // assert *Increment implements Event
	var _ Event = (*PrecisionTiming)(nil) // assert *PrecisionTiming implements Event
	var _ Event = (*Timing)(nil)          // assert *Timing implements Event
	var _ Event = (*Total)(nil)           // assert *Total implements Event
}
529545
func (d Duration) Hour() int {
	_, hour, _, _, _ := splitDuration(d.Duration)
	return hour
}
1280028
func TimeNear(t time.Time, d time.Duration) oglematchers.Matcher {
	return oglematchers.NewMatcher(
		func(c interface{}) error { return timeNear(t, d, c) },
		fmt.Sprintf("within %v of %v", d, t))
}
1115912
func arrow(canvas *svg.SVG, x, y, w, h int, dir string, color string) (xl, yl int) {
	var xp = []int{x, x, x, x}
	var yp = []int{y, y, y, y}

	n := notchsize
	switch dir {
	case "r":
		xp[1] = x - w
		yp[1] = y - h/2
		xp[2] = (x - w) + n
		yp[2] = y
		xp[3] = x - w
		yp[3] = y + h/2
		xl, yl = xp[2], y
	case "l":
		xp[1] = x + w
		yp[1] = y - h/2
		xp[2] = (x + w) - n
		yp[2] = y
		xp[3] = x + w
		yp[3] = y + h/2
		xl, yl = xp[2], y
	case "u":
		xp[1] = x - w/2
		yp[1] = y + h
		xp[2] = x
		yp[2] = (y + h) - n
		xp[3] = x + w/2
		yp[3] = y + h
		xl, yl = x, yp[2]
	case "d":
		xp[1] = x - w/2
		yp[1] = y - h
		xp[2] = x
		yp[2] = (y - h) + n
		xp[3] = x + w/2
		yp[3] = y - h
		xl, yl = x, yp[2]
	}
	canvas.Polygon(xp, yp, "fill:"+color+";fill-opacity:"+lopacity)
	return xl, yl
}
12141
func (t byTime) Less(i, j int) bool {
	return t[i].Time.Before(t[j].Time)
}
761064
func ToTime(i interface{}) time.Time {
	if i == nil {
		return time.Time{}
	}

	if t, ok := i.(int64); ok {
		return time.Unix(t, 0).UTC()
	} else if t, ok := i.(float64); ok {
		return time.Unix(int64(t), 0).UTC()
	} else if t, ok := i.(time.Time); ok {
		return t
	}

	return time.Time{}
}
528203
func translateTimerAttributes(d time.Duration) (attrs map[string]interface{}) {
	attrs = make(map[string]interface{})
	attrs[DisplayTransform] = fmt.Sprintf("x/%d", int64(d))
	attrs[DisplayUnitsShort] = string(unitRegexp.Find([]byte(d.String())))
	return
}
42828
func (r *Linear) Duration() time.Duration {
	a := r.First + time.Duration(r.attempt)*r.Step
	if a < 0 {
		return 0
	}
	if a <= r.Max {
		return a
	}
	return r.Max
}
189381
func (ar *AsyncResult) Get(timeout time.Duration) (interface{}, error) {
	ticker := time.NewTicker(50 * time.Millisecond)
	timeoutChan := time.After(timeout)
	for {
		select {
		case <-timeoutChan:
			err := fmt.Errorf("%v timeout getting result for %s", timeout, ar.TaskID)
			return nil, err
		case <-ticker.C:
			val, err := ar.AsyncGet()
			if err != nil {
				continue
			}
			return val, nil
		}
	}
}
396930
func (db *DB) GetLastScanTimeForTarget(target string) (int64, time.Time, error) {

	var (
		id int64
		t  time.Time
	)

	row := db.QueryRow(`SELECT id, timestamp
			    FROM scans
			    WHERE target=$1 ORDER BY timestamp DESC LIMIT 1`, target)

	err := row.Scan(&id, &t)

	if err != nil {
		if err == sql.ErrNoRows {
			return -1, time.Now(), nil
		} else {
			return -1, time.Now(), err
		}
	}
	return id, t, nil
}