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

Function AddTimeFunctions

checker/standard_library.cc:689–792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

687}
688
689absl::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);

Callers 1

AddStandardLibraryDeclsFunction · 0.85

Calls 8

MakeMemberOverloadDeclFunction · 0.85
AddOverloadMethod · 0.80
IntTypeClass · 0.50
TimestampTypeClass · 0.50
StringTypeClass · 0.50
DurationTypeClass · 0.50
set_nameMethod · 0.45
AddFunctionMethod · 0.45

Tested by

no test coverage detected