MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / BetweenToD

Function BetweenToD

eval/public/extension_func_registrar.cc:122–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122CelValue BetweenToD(Arena* arena, const google::protobuf::Message* time_of_day,
123 const google::protobuf::Message* start, const google::protobuf::Message* stop) {
124 bool is_between;
125 const google::type::TimeOfDay* time_of_day_tod =
126 google::protobuf::DynamicCastMessage<const google::type::TimeOfDay>(time_of_day);
127 const google::type::TimeOfDay* start_tod =
128 google::protobuf::DynamicCastMessage<const google::type::TimeOfDay>(start);
129 const google::type::TimeOfDay* stop_tod =
130 google::protobuf::DynamicCastMessage<const google::type::TimeOfDay>(stop);
131
132 if ((time_of_day_tod == nullptr) || (start_tod == nullptr) ||
133 (stop_tod == nullptr)) {
134 return CreateErrorValue(arena, "Message type downcast failed",
135 absl::StatusCode::kInvalidArgument);
136 }
137 // resolution for TimeOfDay in this function is 1 second
138 int start_time = ToSeconds(start_tod);
139 int stop_time = ToSeconds(stop_tod);
140 int tod_time = ToSeconds(time_of_day_tod);
141
142 is_between = (tod_time >= start_time) && (tod_time < stop_time);
143 return CelValue::CreateBool(is_between);
144}
145
146CelValue BetweenToDStr(Arena* arena, const google::protobuf::Message* time_of_day,
147 absl::string_view start, absl::string_view stop) {

Callers 2

BetweenToDStrFunction · 0.85

Calls 2

CreateErrorValueFunction · 0.85
ToSecondsFunction · 0.85

Tested by

no test coverage detected