package utils

import (
	"time"

	"github.com/gogo/protobuf/types"
)

// TODO(Louis): use MustTimestampProto
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. It returns an error if the resulting Timestamp is invalid.
func TimestampProto(t time.Time) (*types.Timestamp, error) {
	return types.TimestampProto(t)
}

// MustTimestampProto converts the time.Time to a google.protobuf.Timestamp proto. It returns an error if the resulting Timestamp is invalid.
// panic if the time is invalid.
func MustTimestampProto(t time.Time) *types.Timestamp {
	timestamp, err := types.TimestampProto(t)
	if err != nil {
		panic(err)
	}
	return timestamp
}
