MakeDTimestamp creates a DTimestamp with specified precision.
(t time.Time, precision time.Duration)
| 983 | |
| 984 | // MakeDTimestamp creates a DTimestamp with specified precision. |
| 985 | func MakeDTimestamp(t time.Time, precision time.Duration) (*DTimestamp, error) { |
| 986 | ret := t.Round(precision) |
| 987 | if ret.After(MaxSupportedTime) || ret.Before(MinSupportedTime) { |
| 988 | return nil, errors.Newf("timestamp out of range: %q", ret.Format(time.RFC3339)) |
| 989 | } |
| 990 | return &DTimestamp{Time: ret}, nil |
| 991 | } |
| 992 | |
| 993 | // MustMakeDTimestamp wraps MakeDTimestamp but panics if there is an error. |
| 994 | // This is intended for testing applications only. |
no test coverage detected