| 687 | } |
| 688 | |
| 689 | absl::Status AddTimeFunctions(TypeCheckerBuilder& builder) { |
| 690 | FunctionDecl get_full_year; |
| 691 | get_full_year.set_name(StandardFunctions::kFullYear); |
| 692 | CEL_RETURN_IF_ERROR(get_full_year.AddOverload(MakeMemberOverloadDecl( |
| 693 | StandardOverloadIds::kTimestampToYear, IntType(), TimestampType()))); |
| 694 | CEL_RETURN_IF_ERROR(get_full_year.AddOverload( |
| 695 | MakeMemberOverloadDecl(StandardOverloadIds::kTimestampToYearWithTz, |
| 696 | IntType(), TimestampType(), StringType()))); |
| 697 | CEL_RETURN_IF_ERROR(builder.AddFunction(std::move(get_full_year))); |
| 698 | |
| 699 | FunctionDecl get_month; |
| 700 | get_month.set_name(StandardFunctions::kMonth); |
| 701 | CEL_RETURN_IF_ERROR(get_month.AddOverload(MakeMemberOverloadDecl( |
| 702 | StandardOverloadIds::kTimestampToMonth, IntType(), TimestampType()))); |
| 703 | CEL_RETURN_IF_ERROR(get_month.AddOverload( |
| 704 | MakeMemberOverloadDecl(StandardOverloadIds::kTimestampToMonthWithTz, |
| 705 | IntType(), TimestampType(), StringType()))); |
| 706 | CEL_RETURN_IF_ERROR(builder.AddFunction(std::move(get_month))); |
| 707 | |
| 708 | FunctionDecl get_day_of_year; |
| 709 | get_day_of_year.set_name(StandardFunctions::kDayOfYear); |
| 710 | CEL_RETURN_IF_ERROR(get_day_of_year.AddOverload(MakeMemberOverloadDecl( |
| 711 | StandardOverloadIds::kTimestampToDayOfYear, IntType(), TimestampType()))); |
| 712 | CEL_RETURN_IF_ERROR(get_day_of_year.AddOverload( |
| 713 | MakeMemberOverloadDecl(StandardOverloadIds::kTimestampToDayOfYearWithTz, |
| 714 | IntType(), TimestampType(), StringType()))); |
| 715 | CEL_RETURN_IF_ERROR(builder.AddFunction(std::move(get_day_of_year))); |
| 716 | |
| 717 | FunctionDecl get_day_of_month; |
| 718 | get_day_of_month.set_name(StandardFunctions::kDayOfMonth); |
| 719 | CEL_RETURN_IF_ERROR(get_day_of_month.AddOverload( |
| 720 | MakeMemberOverloadDecl(StandardOverloadIds::kTimestampToDayOfMonth, |
| 721 | IntType(), TimestampType()))); |
| 722 | CEL_RETURN_IF_ERROR(get_day_of_month.AddOverload( |
| 723 | MakeMemberOverloadDecl(StandardOverloadIds::kTimestampToDayOfMonthWithTz, |
| 724 | IntType(), TimestampType(), StringType()))); |
| 725 | CEL_RETURN_IF_ERROR(builder.AddFunction(std::move(get_day_of_month))); |
| 726 | |
| 727 | FunctionDecl get_date; |
| 728 | get_date.set_name(StandardFunctions::kDate); |
| 729 | CEL_RETURN_IF_ERROR(get_date.AddOverload(MakeMemberOverloadDecl( |
| 730 | StandardOverloadIds::kTimestampToDate, IntType(), TimestampType()))); |
| 731 | CEL_RETURN_IF_ERROR(get_date.AddOverload( |
| 732 | MakeMemberOverloadDecl(StandardOverloadIds::kTimestampToDateWithTz, |
| 733 | IntType(), TimestampType(), StringType()))); |
| 734 | CEL_RETURN_IF_ERROR(builder.AddFunction(std::move(get_date))); |
| 735 | |
| 736 | FunctionDecl get_day_of_week; |
| 737 | get_day_of_week.set_name(StandardFunctions::kDayOfWeek); |
| 738 | CEL_RETURN_IF_ERROR(get_day_of_week.AddOverload(MakeMemberOverloadDecl( |
| 739 | StandardOverloadIds::kTimestampToDayOfWeek, IntType(), TimestampType()))); |
| 740 | CEL_RETURN_IF_ERROR(get_day_of_week.AddOverload( |
| 741 | MakeMemberOverloadDecl(StandardOverloadIds::kTimestampToDayOfWeekWithTz, |
| 742 | IntType(), TimestampType(), StringType()))); |
| 743 | CEL_RETURN_IF_ERROR(builder.AddFunction(std::move(get_day_of_week))); |
| 744 | |
| 745 | FunctionDecl get_hours; |
| 746 | get_hours.set_name(StandardFunctions::kHours); |
no test coverage detected