// ParseTimestamp return a timestamp, if there is no timestamp on the csv it
// will be the current timestamp, else it will try to parse the time according
// to the format.
512642
func parseTimestamp(timeFunc func() time.Time, recordFields map[string]interface{},
	timestampColumn, timestampFormat string,
) (metricTime time.Time, err error) {
	metricTime = timeFunc()

	if timestampColumn != "" {
		if recordFields[timestampColumn] == nil {
			err = fmt.Errorf("timestamp column: %v could not be found", timestampColumn)
			return
		}

		tStr := fmt.Sprintf("%v", recordFields[timestampColumn])

		switch timestampFormat {
		case "":
			err = fmt.Errorf("timestamp format must be specified")
			return
		default:
			metricTime, err = internal.ParseTimestamp(tStr, timestampFormat)
			if err != nil {
				return
			}
		}
	}
	return
}
202411
func (s *DataPoint) SetTimestamp(v time.Time) *DataPoint {
	s.Timestamp = &v
	return s
}
432572
func (s *StackEvent) SetTimestamp(v time.Time) *StackEvent {
	s.Timestamp = &v
	return s
}
274860
func ParseTime(influxQL string, now time.Time) (time.Duration, error) {
	start := strings.Index(strings.ToUpper(influxQL), WhereToken)
	if start == -1 {
		return 0, fmt.Errorf("not a relative duration")
	}
	start += len(WhereToken)
	where := influxQL[start:]
	cond, err := influxql.ParseExpr(where)
	if err != nil {
		return 0, err
	}
	nowVal := &influxql.NowValuer{
		Now: now,
	}
	cond = influxql.Reduce(cond, nowVal)
	min, max, err := TimeRangeAsEpochNano(cond, now)
	if err != nil {
		return 0, err
	}
	dur := time.Duration(max - min)
	if dur < 0 {
		dur = 0
	}
	return dur, nil
}
844718
func (s *MeterUsageInput) SetTimestamp(v time.Time) *MeterUsageInput {
	s.Timestamp = &v
	return s
}
377871
func (s *TrustedAdvisorCheckResult) SetTimestamp(v string) *TrustedAdvisorCheckResult {
	s.Timestamp = &v
	return s
}
1140321
func parseTime(t interface{}) (time.Time, error) {
	var err error
	var calcTime time.Time
	switch v := t.(type) {
	case string:
		if calcTime, err = time.Parse(TimeFormat, v); err != nil {
			return time.Time{}, errors.New("cannot parse string time")
		}
	case int64:
		calcTime = time.Unix(v, 0).UTC()
	default:
		return time.Time{}, errors.New("arg must be a timestamp")
	}
	return calcTime, nil
}
699586
func (s *SamplingStatisticSummary) SetTimestamp(v time.Time) *SamplingStatisticSummary {
	s.Timestamp = &v
	return s
}
1160106
func (s *Session) SetStopTimestamp(v string) *Session {
	s.StopTimestamp = &v
	return s
}
919193
func (s *AlarmHistoryItem) SetTimestamp(v time.Time) *AlarmHistoryItem {
	s.Timestamp = &v
	return s
}
794159
func (c *Carbon) SetTimestamp(sec int64) {
	c.Time = time.Unix(sec, 0).In(c.Location())
}
811161
func (a *DispatchTouchEventArgs) SetTimestamp(timestamp TimeSinceEpoch) *DispatchTouchEventArgs {
	a.Timestamp = timestamp
	return a
}
363432
func (s *PhoneNumber) SetDeletionTimestamp(v time.Time) *PhoneNumber {
	s.DeletionTimestamp = &v
	return s
}
1240109
func ParseDatapointTimestamp(timestamp string) (*time.Time, error) {
	if timestamp == "" {
		return nil, errors.New("Received an empty timestamp")
	}
	parsed, err := time.Parse(time.RFC3339, timestamp)
	if err != nil {
		return nil, err
	}
	return &parsed, nil
}
54180
func (s *GetDatasetContentOutput) SetTimestamp(v time.Time) *GetDatasetContentOutput {
	s.Timestamp = &v
	return s
}
284031
func (s *Datapoint) SetTimestamp(v time.Time) *Datapoint {
	s.Timestamp = &v
	return s
}
660158
func (s *LabelDetection) SetTimestamp(v int64) *LabelDetection {
	s.Timestamp = &v
	return s
}