// ParseTimestampFromNum is a helper function wrapping ParseTimeFromNum with timestamp type and default fsp.
169623
func ParseTimestampFromNum(num int64) (Time, error) {
	return ParseTimeFromNum(num, mysql.TypeTimestamp, DefaultFsp)
}
687298
func (s *ContentModerationDetection) SetTimestamp(v int64) *ContentModerationDetection {
	s.Timestamp = &v
	return s
}
1101621
func (pt *ParseTime) RFC8xx1123(value string) (time.Time, error) {
	t, _, err := parseRFC8xx1123(value, pt.location)
	return t, err
}
1049147
func (s *StackResourceDrift) SetTimestamp(v time.Time) *StackResourceDrift {
	s.Timestamp = &v
	return s
}
122840
func ParseTimestamp(sc *stmtctx.StatementContext, str string) (Time, error) {
	return ParseTime(sc, str, mysql.TypeTimestamp, GetFsp(str))
}
1253149
func parseDateTimeFromNum(sc *stmtctx.StatementContext, num int64) (Time, error) {
	t := ZeroDate
	// Check zero.
	if num == 0 {
		return t, nil
	}

	// Check datetime type.
	if num >= 10000101000000 {
		t.Type = mysql.TypeDatetime
		return getTime(sc, num, t.Type)
	}

	// Check MMDD.
	if num < 101 {
		return t, errors.Trace(ErrInvalidTimeFormat.GenWithStackByArgs(num))
	}

	// Adjust year
	// YYMMDD, year: 2000-2069
	if num <= (70-1)*10000+1231 {
		num = (num + 20000000) * 1000000
		return getTime(sc, num, t.Type)
	}

	// Check YYMMDD.
	if num < 70*10000+101 {
		return t, errors.Trace(ErrInvalidTimeFormat.GenWithStackByArgs(num))
	}

	// Adjust year
	// YYMMDD, year: 1970-1999
	if num <= 991231 {
		num = (num + 19000000) * 1000000
		return getTime(sc, num, t.Type)
	}

	// Check YYYYMMDD.
	if num < 10000101 {
		return t, errors.Trace(ErrInvalidTimeFormat.GenWithStackByArgs(num))
	}

	// Adjust hour/min/second.
	if num <= 99991231 {
		num = num * 1000000
		return getTime(sc, num, t.Type)
	}

	// Check MMDDHHMMSS.
	if num < 101000000 {
		return t, errors.Trace(ErrInvalidTimeFormat.GenWithStackByArgs(num))
	}

	// Set TypeDatetime type.
	t.Type = mysql.TypeDatetime

	// Adjust year
	// YYMMDDHHMMSS, 2000-2069
	if num <= 69*10000000000+1231235959 {
		num = num + 20000000000000
		return getTime(sc, num, t.Type)
	}

	// Check YYYYMMDDHHMMSS.
	if num < 70*10000000000+101000000 {
		return t, errors.Trace(ErrInvalidTimeFormat.GenWithStackByArgs(num))
	}

	// Adjust year
	// YYMMDDHHMMSS, 1970-1999
	if num <= 991231235959 {
		num = num + 19000000000000
		return getTime(sc, num, t.Type)
	}

	return getTime(sc, num, t.Type)
}
844718
func (s *MeterUsageInput) SetTimestamp(v time.Time) *MeterUsageInput {
	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
}
1045190
func interpolationFuncTimestamp() ast.Function {
	return ast.Function{
		ArgTypes:   []ast.Type{},
		ReturnType: ast.TypeString,
		Callback: func(args []interface{}) (interface{}, error) {
			return time.Now().UTC().Format(time.RFC3339), nil
		},
	}
}
986635
func (s *FilteredLogEvent) SetTimestamp(v int64) *FilteredLogEvent {
	s.Timestamp = &v
	return s
}
1046380
func (s *Event) SetTimestamp(v string) *Event {
	s.Timestamp = &v
	return s
}
296981
func ParseDatetimeFromNum(sc *stmtctx.StatementContext, num int64) (Time, error) {
	return ParseTimeFromNum(sc, num, mysql.TypeDatetime, DefaultFsp)
}
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
}
718416
func (s *DomainMetadataOutput) SetTimestamp(v int64) *DomainMetadataOutput {
	s.Timestamp = &v
	return s
}
1052547
func NewTimestampTsCellFromInt64(v int64) TsCell {
	tsc := riak_ts.TsCell{TimestampValue: &v}
	tsct := riak_ts.TsColumnType_TIMESTAMP
	return TsCell{columnType: tsct, cell: &tsc}
}
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
}
722607
func ConvertToTimestamp(timeString string) *Timestamp {
	parsed, _ := time.Parse(time.RFC3339Nano, timeString)
	return &Timestamp{parsed}
}