// TimeToProto converts the time.Time to a logutilpb.Time.
18426
func TimeToProto(t time.Time) *logutilpb.Time {
	seconds := t.Unix()
	nanos := int64(t.Sub(time.Unix(seconds, 0)))
	return &logutilpb.Time{
		Seconds:     seconds,
		Nanoseconds: int32(nanos),
	}
}
495058
func (m GatewayIDMetadata) ToProto() *pb.Metadata {
	return &pb.Metadata{
		Metadata: &pb.Metadata_GatewayID{
			GatewayID: m.GatewayID,
		},
	}
}
724693
func SetTimeRotated(timeRotated bool) {
	singltonLock.RLock()
	defer singltonLock.RUnlock()

	blog.SetTimeRotated(timeRotated)
}
860957
func MustTimestampProto(t time.Time) *gogotypes.Timestamp {
	ts, err := gogotypes.TimestampProto(t)
	if err != nil {
		panic(err.Error())
	}
	return ts
}
1313245
func (engine *Engine) NoAutoTime() *Session {
	session := engine.NewSession()
	session.isAutoClose = true
	return session.NoAutoTime()
}
1354094
func Time(key string, t time.Time) log.Field {
	return log.String(key, t.Format(time.RFC3339))
}
1133509
func (writer *baseFileWriter) SetTimeRotated(timeRotated bool) {
	writer.lock.Lock()
	defer writer.lock.Unlock()
	writer.timeRotated = timeRotated
}
905346
func (e *Execution) ToProto(includeID bool) *dm.Execution {
	ret := &dm.Execution{Data: e.DataProto()}
	if includeID {
		ret.Id = e.GetEID()
	}
	return ret
}
22245
func (op *Operation) ToProto(wrappedID string) *api.UploadOperation {
	var ref *api.ObjectRef
	if op.Status == api.UploadStatus_PUBLISHED {
		ref = &api.ObjectRef{
			HashAlgo:  op.HashAlgo,
			HexDigest: op.HexDigest,
		}
	}
	return &api.UploadOperation{
		OperationId:  wrappedID,
		UploadUrl:    op.UploadURL,
		Status:       op.Status,
		Object:       ref,
		ErrorMessage: op.Error,
	}
}
1180633
func (dt *DeleteTable) ToProto() proto.Message {
	return &pb.DeleteTableRequest{
		TableName: &pb.TableName{
			// TODO: hadle namespaces properly
			Namespace: []byte("default"),
			Qualifier: dt.table,
		},
	}
}
900212
func stateToProto(state PluginState) status.OperationalState {
	switch state {
	case Init:
		return status.OperationalState_INIT
	case OK:
		return status.OperationalState_OK
	default:
		return status.OperationalState_ERROR
	}
}
1052714
func (v *Value) ToTimestamp() (t time.Time, ok bool) {
	switch v.vType {
	case typeTimestamp:
		return v.value.(time.Time), true
	}
	return t, false
}
664746
func Time(t time.Time) NullTime {
	return NullTime{
		pq.NullTime{
			Time:  t,
			Valid: true,
		},
	}
}
1348243
func (w *WindowedSchedule) setStopOnTime() {
	if w.StopTime == nil && w.Count != 0 {
		// determine the window stop based on the `count` and `interval`
		var newStop time.Time

		// if start is not set or points in the past,
		// use the current time to calculate stopOnTime
		if w.StartTime != nil && time.Now().Before(*w.StartTime) {
			newStop = w.StartTime.Add(time.Duration(w.Count) * w.Interval)
		} else {
			// set a new stop timestamp from this point in time
			newStop = time.Now().Add(time.Duration(w.Count) * w.Interval)
		}
		// set calculated new stop
		w.stopOnTime = &newStop
		return
	}

	// stopOnTime is determined by StopTime
	w.stopOnTime = w.StopTime
}
696577
func (m AppIDMetadata) ToProto() *pb.Metadata {
	return &pb.Metadata{
		Metadata: &pb.Metadata_AppID{
			AppID: m.AppID,
		},
	}
}
82092
func (p Permissions) ToProto(validTime time.Duration) *access.PermittedActionsResponse {
	perms := make(map[string]*access.PermittedActionsResponse_ResourcePermissions, len(p))
	for bucket, action := range p {
		var actions []string
		for a, name := range actionToName {
			if action&a == a {
				actions = append(actions, name)
			}
		}
		sort.Strings(actions)
		perms[bucket] = &access.PermittedActionsResponse_ResourcePermissions{Actions: actions}
	}
	return &access.PermittedActionsResponse{
		Permitted:        perms,
		ValidityDuration: ptypes.DurationProto(validTime),
	}
}
562639
func (m PrefixMetadata) ToProto() *pb.Metadata {
	return &pb.Metadata{
		Metadata: &pb.Metadata_DevAddrPrefix{
			DevAddrPrefix: m.Prefix.Bytes(),
		},
	}
}