// Timeline returns a JSON parsable string that can be fed into a viz timeline component.
966361
func (bp *BuildPage) Timeline() string {
	// Return the cached version, if it exists already.
	if bp.timelineData != "" {
		return bp.timelineData
	}

	// stepData is extra data to deliver with the groups and items (see below) for the
	// Javascript vis Timeline component. Note that the step data is encoded in markdown
	// in the step.SummaryMarkdown field. We do not show this data on the timeline at this
	// time.
	type stepData struct {
		Label           string `json:"label"`
		Duration        string `json:"duration"`
		LogURL          string `json:"logUrl"`
		StatusClassName string `json:"statusClassName"`
	}

	// group corresponds to, and matches the shape of, a Group for the Javascript
	// vis Timeline component http://visjs.org/docs/timeline/#groups. Data
	// rides along as an extra property (unused by vis Timeline itself) used
	// in client side rendering. Each Group is rendered as its own row in the
	// timeline component on to which Items are rendered. Currently we only render
	// one Item per Group, that is one thing per row.
	type group struct {
		ID   string   `json:"id"`
		Data stepData `json:"data"`
	}

	// item corresponds to, and matches the shape of, an Item for the Javascript
	// vis Timeline component http://visjs.org/docs/timeline/#items. Data
	// rides along as an extra property (unused by vis Timeline itself) used
	// in client side rendering. Each Item is rendered to a Group which corresponds
	// to a row. Currently we only render one Item per Group, that is one thing per
	// row.
	type item struct {
		ID        string   `json:"id"`
		Group     string   `json:"group"`
		Start     int64    `json:"start"`
		End       int64    `json:"end"`
		Type      string   `json:"type"`
		ClassName string   `json:"className"`
		Data      stepData `json:"data"`
	}

	groups := make([]group, len(bp.Build.Steps))
	items := make([]item, len(bp.Build.Steps))
	for i, step := range bp.Build.Steps {
		groupID := strconv.Itoa(i)
		logURL := ""
		if len(step.Logs) > 0 {
			logURL = html.EscapeString(step.Logs[0].ViewUrl)
		}
		statusClassName := fmt.Sprintf("status-%s", step.Status)
		data := stepData{
			Label:           html.EscapeString(step.Name),
			Duration:        common.Duration(step.StartTime, step.EndTime, bp.Now),
			LogURL:          logURL,
			StatusClassName: statusClassName,
		}
		groups[i] = group{groupID, data}
		start, _ := ptypes.Timestamp(step.StartTime)
		end, _ := ptypes.Timestamp(step.EndTime)
		items[i] = item{
			ID:        groupID,
			Group:     groupID,
			Start:     milliseconds(start),
			End:       milliseconds(end),
			Type:      "range",
			ClassName: statusClassName,
			Data:      data,
		}
	}

	timeline, err := json.Marshal(map[string]interface{}{
		"groups": groups,
		"items":  items,
	})
	if err != nil {
		bp.Errors = append(bp.Errors, err)
		return "error"
	}
	return string(timeline)
}
446932
func (r *RoomService) History(id string, opt *HistoryOptions) (*History, *http.Response, error) {
	u := fmt.Sprintf("room/%s/history", id)
	req, err := r.client.NewRequest("GET", u, opt, nil)
	h := new(History)
	resp, err := r.client.Do(req, &h)
	if err != nil {
		return nil, resp, err
	}
	return h, resp, nil
}
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
}
191527
func (s *TimelineService) UserTimeline(params *UserTimelineParams) ([]Tweet, *http.Response, error) {
	tweets := new([]Tweet)
	apiError := new(APIError)
	resp, err := s.sling.New().Get("user_timeline.json").QueryStruct(params).Receive(tweets, apiError)
	return *tweets, resp, relevantError(err, *apiError)
}
1253951
func Timing(metric string, value time.Duration) {
	DefaultClient.Timing(metric, value)
}
551070
func (b ValExprBuilder) Between(from interface{}, to interface{}) BoolExprBuilder {
	return b.makeRangeCond(astBetween, from, to)
}
1137393
func (e *JSONEncoder) EncodeHistory(res *HistoryResult) ([]byte, error) {
	return json.Marshal(res)
}
342306
func (handler *Handler) Next(timeout time.Duration) *event.Event {
	var logEvent *event.Event
	if timeout == 0 {
		select {
		case logEvent = <-handler.channel:
		default:
		}
	} else {
		select {
		case logEvent = <-handler.channel:
		case <-time.After(timeout):
		}
	}
	return logEvent
}
793966
func (api *Client) GetConversationHistory(params *GetConversationHistoryParameters) (*GetConversationHistoryResponse, error) {
	return api.GetConversationHistoryContext(context.Background(), params)
}
511757
func (v vars) Now(layout string) string {
	return time.Now().Format(layout)
}
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
}
732626
func (l Links) Prev(href string, args ...interface{}) Links {
	return l.Link("prev", href, args...)
}
892056
func (p *MediaPlaylist) DurationAsInt(yes bool) {
	if yes {
		// duration must be integers if protocol version is less than 3
		version(&p.ver, 3)
	}
	p.durationAsInt = yes
}
528223
func (s *Stream) Time() time.Duration {
	return duration(C.Pa_GetStreamTime(s.paStream))
}
473320
func SequenceView(meta SequenceMeta, rs ...Renderable) *View {
	return MakeView(meta.UID, trees.SimpleMarkupWriter, Sequence(meta, rs...))
}
790476
func (c *StatsdClient) Timing(stat string, delta int64) error {
	return c.TimingWithSampling(stat, delta, 1)
}
540594
func (c *expvarStatsClient) Timing(name string, value time.Duration, rate float64) {
	c.mu.Lock()
	d, _ := c.m.Get(name).(time.Duration)
	c.m.Set(name, d+value)
	c.mu.Unlock()
}