34 lines
471 B
Go
34 lines
471 B
Go
package utils
|
|
|
|
import (
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
"time"
|
|
)
|
|
|
|
func TimeP(t *timestamppb.Timestamp) *time.Time {
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
tt := t.AsTime()
|
|
return &tt
|
|
}
|
|
|
|
func TimestampP(t *time.Time) *timestamppb.Timestamp {
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
return timestamppb.New(*t)
|
|
}
|
|
|
|
func AsTimeP(t time.Time) *time.Time {
|
|
return &t
|
|
}
|
|
|
|
func AsInt32P(v int32) *int32 {
|
|
return &v
|
|
}
|
|
|
|
func AsStringP(str string) *string {
|
|
return &str
|
|
}
|