const minValidSeconds … const maxValidSeconds … // Timestamp converts a timestamppb.Timestamp to a time.Time. // It returns an error if the argument is invalid. // // Unlike most Go functions, if Timestamp returns an error, the first return // value is not the zero time.Time. Instead, it is the value obtained from the // time.Unix function when passed the contents of the Timestamp, in the UTC // locale. This may or may not be a meaningful time; many invalid Timestamps // do map to valid time.Times. // // A nil Timestamp returns an error. The first return value in that case is // undefined. // // Deprecated: Call the ts.AsTime and ts.CheckValid methods instead. func Timestamp(ts *timestamppb.Timestamp) (time.Time, error) { … } // TimestampNow returns a google.protobuf.Timestamp for the current time. // // Deprecated: Call the timestamppb.Now function instead. func TimestampNow() *timestamppb.Timestamp { … } // TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. // It returns an error if the resulting Timestamp is invalid. // // Deprecated: Call the timestamppb.New function instead. func TimestampProto(t time.Time) (*timestamppb.Timestamp, error) { … } // TimestampString returns the RFC 3339 string for valid Timestamps. // For invalid Timestamps, it returns an error message in parentheses. // // Deprecated: Call the ts.AsTime method instead, // followed by a call to the Format method on the time.Time value. func TimestampString(ts *timestamppb.Timestamp) string { … } // validateTimestamp determines whether a Timestamp is valid. // A valid timestamp represents a time in the range [0001-01-01, 10000-01-01) // and has a Nanos field in the range [0, 1e9). // // If the Timestamp is valid, validateTimestamp returns nil. // Otherwise, it returns an error that describes the problem. // // Every valid Timestamp can be represented by a time.Time, // but the converse is not true. func validateTimestamp(ts *timestamppb.Timestamp) error { … }