| 161 | } |
| 162 | |
| 163 | absl::Status RegisterTimestampFunctions(FunctionRegistry& registry, |
| 164 | const RuntimeOptions& options) { |
| 165 | CEL_RETURN_IF_ERROR(registry.Register( |
| 166 | BinaryFunctionAdapter<Value, absl::Time, const StringValue&>:: |
| 167 | CreateDescriptor(builtin::kFullYear, true), |
| 168 | BinaryFunctionAdapter<Value, absl::Time, const StringValue&>:: |
| 169 | WrapFunction([](absl::Time ts, const StringValue& tz) -> Value { |
| 170 | return GetFullYear(ts, tz.ToString()); |
| 171 | }))); |
| 172 | |
| 173 | CEL_RETURN_IF_ERROR(registry.Register( |
| 174 | UnaryFunctionAdapter<Value, absl::Time>::CreateDescriptor( |
| 175 | builtin::kFullYear, true), |
| 176 | UnaryFunctionAdapter<Value, absl::Time>::WrapFunction( |
| 177 | [](absl::Time ts) -> Value { return GetFullYear(ts, ""); }))); |
| 178 | |
| 179 | CEL_RETURN_IF_ERROR(registry.Register( |
| 180 | BinaryFunctionAdapter<Value, absl::Time, const StringValue&>:: |
| 181 | CreateDescriptor(builtin::kMonth, true), |
| 182 | BinaryFunctionAdapter<Value, absl::Time, const StringValue&>:: |
| 183 | WrapFunction([](absl::Time ts, const StringValue& tz) -> Value { |
| 184 | return GetMonth(ts, tz.ToString()); |
| 185 | }))); |
| 186 | |
| 187 | CEL_RETURN_IF_ERROR(registry.Register( |
| 188 | UnaryFunctionAdapter<Value, absl::Time>::CreateDescriptor(builtin::kMonth, |
| 189 | true), |
| 190 | UnaryFunctionAdapter<Value, absl::Time>::WrapFunction( |
| 191 | [](absl::Time ts) -> Value { return GetMonth(ts, ""); }))); |
| 192 | |
| 193 | CEL_RETURN_IF_ERROR(registry.Register( |
| 194 | BinaryFunctionAdapter<Value, absl::Time, const StringValue&>:: |
| 195 | CreateDescriptor(builtin::kDayOfYear, true), |
| 196 | BinaryFunctionAdapter<Value, absl::Time, const StringValue&>:: |
| 197 | WrapFunction([](absl::Time ts, const StringValue& tz) -> Value { |
| 198 | return GetDayOfYear(ts, tz.ToString()); |
| 199 | }))); |
| 200 | |
| 201 | CEL_RETURN_IF_ERROR(registry.Register( |
| 202 | UnaryFunctionAdapter<Value, absl::Time>::CreateDescriptor( |
| 203 | builtin::kDayOfYear, true), |
| 204 | UnaryFunctionAdapter<Value, absl::Time>::WrapFunction( |
| 205 | [](absl::Time ts) -> Value { return GetDayOfYear(ts, ""); }))); |
| 206 | |
| 207 | CEL_RETURN_IF_ERROR(registry.Register( |
| 208 | BinaryFunctionAdapter<Value, absl::Time, const StringValue&>:: |
| 209 | CreateDescriptor(builtin::kDayOfMonth, true), |
| 210 | BinaryFunctionAdapter<Value, absl::Time, const StringValue&>:: |
| 211 | WrapFunction([](absl::Time ts, const StringValue& tz) -> Value { |
| 212 | return GetDayOfMonth(ts, tz.ToString()); |
| 213 | }))); |
| 214 | |
| 215 | CEL_RETURN_IF_ERROR(registry.Register( |
| 216 | UnaryFunctionAdapter<Value, absl::Time>::CreateDescriptor( |
| 217 | builtin::kDayOfMonth, true), |
| 218 | UnaryFunctionAdapter<Value, absl::Time>::WrapFunction( |
| 219 | [](absl::Time ts) -> Value { return GetDayOfMonth(ts, ""); }))); |
| 220 |
no test coverage detected