// generateTimestamp generates a new timestamp from the previous one in the store - this assumes all
// the other roles have already been set on the repo, and will set the generated timestamp on the repo as well
335366
func generateTimestamp(gun data.GUN, builder tuf.RepoBuilder, store storage.MetaStore) (*storage.MetaUpdate, error) {
	var prev *data.SignedTimestamp
	_, currentJSON, err := store.GetCurrent(gun, data.CanonicalTimestampRole)

	switch err.(type) {
	case nil:
		prev = new(data.SignedTimestamp)
		if err := json.Unmarshal(currentJSON, prev); err != nil {
			logrus.Error("Failed to unmarshal existing timestamp for GUN ", gun)
			return nil, err
		}
	case storage.ErrNotFound:
		break // this is the first timestamp ever for the repo
	default:
		return nil, err
	}

	meta, ver, err := builder.GenerateTimestamp(prev)

	switch err.(type) {
	case nil:
		return &storage.MetaUpdate{
			Role:    data.CanonicalTimestampRole,
			Version: ver,
			Data:    meta,
		}, nil
	case signed.ErrInsufficientSignatures, signed.ErrNoKeys:
		// If we cannot sign the timestamp, then we don't have keys for the timestamp,
		// and the client screwed up their root
		return nil, validation.ErrBadRoot{
			Msg: fmt.Sprintf("no  timestamp keys exist on the server"),
		}
	default:
		return nil, validation.ErrValidation{Msg: err.Error()}
	}
}
339179
func (o *pdOracle) GetTimestamp(ctx context.Context) (uint64, error) {
	ts, err := o.getTimestamp(ctx)
	if err != nil {
		return 0, errors.Trace(err)
	}
	o.setLastTS(ts)
	return ts, nil
}
393882
func (s *CreateLoggerDefinitionOutput) SetLastUpdatedTimestamp(v string) *CreateLoggerDefinitionOutput {
	s.LastUpdatedTimestamp = &v
	return s
}
857031
func (s *MetricDatapoint) SetTimestamp(v time.Time) *MetricDatapoint {
	s.Timestamp = &v
	return s
}
919193
func (s *AlarmHistoryItem) SetTimestamp(v time.Time) *AlarmHistoryItem {
	s.Timestamp = &v
	return s
}
136286
func MakeTimestamp(db XODB, v0 int, v1 int, v2 int, v3 int, v4 int, v5 float64) (time.Time, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.make_timestamp($1, $2, $3, $4, $5, $6)`

	// run query
	var ret time.Time
	XOLog(sqlstr, v0, v1, v2, v3, v4, v5)
	err = db.QueryRow(sqlstr, v0, v1, v2, v3, v4, v5).Scan(&ret)
	if err != nil {
		return time.Time{}, err
	}

	return ret, nil
}
678072
func (s *TerminationHealth) SetTimestamp(v time.Time) *TerminationHealth {
	s.Timestamp = &v
	return s
}
36747
func (s *MetricData) SetTimestamp(v time.Time) *MetricData {
	s.Timestamp = &v
	return s
}
1048582
func (a *DispatchMouseEventArgs) SetTimestamp(timestamp TimeSinceEpoch) *DispatchMouseEventArgs {
	a.Timestamp = timestamp
	return a
}
836135
func (s *Activity) SetTimeStamp(v time.Time) *Activity {
	s.TimeStamp = &v
	return s
}
722607
func ConvertToTimestamp(timeString string) *Timestamp {
	parsed, _ := time.Parse(time.RFC3339Nano, timeString)
	return &Timestamp{parsed}
}
1150758
func (s *DeleteApplicationInput) SetCreateTimestamp(v time.Time) *DeleteApplicationInput {
	s.CreateTimestamp = &v
	return s
}
54180
func (s *GetDatasetContentOutput) SetTimestamp(v time.Time) *GetDatasetContentOutput {
	s.Timestamp = &v
	return s
}
1046380
func (s *Event) SetTimestamp(v string) *Event {
	s.Timestamp = &v
	return s
}
644120
func addTimestamp(buffer *bytes.Buffer) {
	now := now()
	year, month, day := now.Date()
	hour, minute, second := now.Clock()

	var tmp = new([23]byte)
	writeInt(tmp, 4, 0, year)
	tmp[4] = '-'
	writeInt(tmp, 2, 5, int(month))
	tmp[7] = '-'
	writeInt(tmp, 2, 8, day)
	tmp[10] = ' '
	writeInt(tmp, 2, 11, hour)
	tmp[13] = ':'
	writeInt(tmp, 2, 14, minute)
	tmp[16] = ':'
	writeInt(tmp, 2, 17, second)
	tmp[19] = '.'
	writeInt(tmp, 3, 20, now.Nanosecond()/1000000)
	buffer.Write(tmp[:])
}
1315900
func (b *BackupEngineInfo) GetTimestamp(index int) int64 {
	return int64(C.rocksdb_backup_engine_info_timestamp(b.c, C.int(index)))
}
1049147
func (s *StackResourceDrift) SetTimestamp(v time.Time) *StackResourceDrift {
	s.Timestamp = &v
	return s
}