2424#include " absl/strings/string_view.h"
2525#include " absl/time/time.h"
2626#include " internal/status_macros.h"
27+ #include " google/protobuf/util/time_util.h"
2728
2829namespace cel ::internal {
2930
@@ -36,6 +37,38 @@ std::string RawFormatTimestamp(absl::Time timestamp) {
3637
3738} // namespace
3839
40+ absl::Duration MaxDuration () {
41+ // This currently supports a larger range then the current CEL spec. The
42+ // intent is to widen the CEL spec to support the larger range and match
43+ // google.protobuf.Duration from protocol buffer messages, which this
44+ // implementation currently supports.
45+ // TODO(google/cel-spec/issues/214): revisit
46+ return absl::Seconds (google::protobuf::util::TimeUtil::kDurationMaxSeconds ) +
47+ absl::Nanoseconds (google::protobuf::util::TimeUtil::kDurationMaxNanoseconds );
48+ }
49+
50+ absl::Duration MinDuration () {
51+ // This currently supports a larger range then the current CEL spec. The
52+ // intent is to widen the CEL spec to support the larger range and match
53+ // google.protobuf.Duration from protocol buffer messages, which this
54+ // implementation currently supports.
55+ // TODO(google/cel-spec/issues/214): revisit
56+ return absl::Seconds (google::protobuf::util::TimeUtil::kDurationMinSeconds ) +
57+ absl::Nanoseconds (google::protobuf::util::TimeUtil::kDurationMinNanoseconds );
58+ }
59+
60+ absl::Time MaxTimestamp () {
61+ return absl::UnixEpoch () +
62+ absl::Seconds (google::protobuf::util::TimeUtil::kTimestampMaxSeconds ) +
63+ absl::Nanoseconds (google::protobuf::util::TimeUtil::kTimestampMaxNanoseconds );
64+ }
65+
66+ absl::Time MinTimestamp () {
67+ return absl::UnixEpoch () +
68+ absl::Seconds (google::protobuf::util::TimeUtil::kTimestampMinSeconds ) +
69+ absl::Nanoseconds (google::protobuf::util::TimeUtil::kTimestampMinNanoseconds );
70+ }
71+
3972absl::Status ValidateDuration (absl::Duration duration) {
4073 if (duration < MinDuration ()) {
4174 return absl::InvalidArgumentError (
0 commit comments