void RegisterScalarTemporalUnary()

in cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc [1843:2034]


void RegisterScalarTemporalUnary(FunctionRegistry* registry) {
  // Date extractors
  auto year =
      UnaryTemporalFactory<Year, TemporalComponentExtract,
                           Int64Type>::Make<WithDates, WithTimestamps>("year", int64(),
                                                                       year_doc);
  DCHECK_OK(registry->AddFunction(std::move(year)));

  auto is_leap_year =
      UnaryTemporalFactory<IsLeapYear, TemporalComponentExtract, BooleanType>::Make<
          WithDates, WithTimestamps>("is_leap_year", boolean(), is_leap_year_doc);
  DCHECK_OK(registry->AddFunction(std::move(is_leap_year)));

  auto month =
      UnaryTemporalFactory<Month, TemporalComponentExtract,
                           Int64Type>::Make<WithDates, WithTimestamps>("month", int64(),
                                                                       month_doc);
  DCHECK_OK(registry->AddFunction(std::move(month)));

  auto day =
      UnaryTemporalFactory<Day, TemporalComponentExtract,
                           Int64Type>::Make<WithDates, WithTimestamps>("day", int64(),
                                                                       day_doc);
  DCHECK_OK(registry->AddFunction(std::move(day)));

  auto year_month_day =
      SimpleUnaryTemporalFactory<YearMonthDay>::Make<WithDates, WithTimestamps>(
          "year_month_day", YearMonthDayType(), year_month_day_doc);
  DCHECK_OK(registry->AddFunction(std::move(year_month_day)));

  static const auto default_day_of_week_options = DayOfWeekOptions::Defaults();
  auto day_of_week =
      UnaryTemporalFactory<DayOfWeek, TemporalComponentExtractDayOfWeek, Int64Type>::Make<
          WithDates, WithTimestamps>("day_of_week", int64(), day_of_week_doc,
                                     &default_day_of_week_options, DayOfWeekState::Init);
  DCHECK_OK(registry->AddFunction(std::move(day_of_week)));

  auto day_of_year =
      UnaryTemporalFactory<DayOfYear, TemporalComponentExtract,
                           Int64Type>::Make<WithDates, WithTimestamps>("day_of_year",
                                                                       int64(),
                                                                       day_of_year_doc);
  DCHECK_OK(registry->AddFunction(std::move(day_of_year)));

  auto iso_year =
      UnaryTemporalFactory<ISOYear, TemporalComponentExtract,
                           Int64Type>::Make<WithDates, WithTimestamps>("iso_year",
                                                                       int64(),
                                                                       iso_year_doc);
  DCHECK_OK(registry->AddFunction(std::move(iso_year)));

  auto us_year =
      UnaryTemporalFactory<USYear, TemporalComponentExtract,
                           Int64Type>::Make<WithDates, WithTimestamps>("us_year", int64(),
                                                                       us_year_doc);
  DCHECK_OK(registry->AddFunction(std::move(us_year)));

  static const auto default_iso_week_options = WeekOptions::ISODefaults();
  auto iso_week =
      UnaryTemporalFactory<Week, TemporalComponentExtractWeek, Int64Type>::Make<
          WithDates, WithTimestamps>("iso_week", int64(), iso_week_doc,
                                     &default_iso_week_options, WeekState::Init);
  DCHECK_OK(registry->AddFunction(std::move(iso_week)));

  static const auto default_us_week_options = WeekOptions::USDefaults();
  auto us_week =
      UnaryTemporalFactory<Week, TemporalComponentExtractWeek, Int64Type>::Make<
          WithDates, WithTimestamps>("us_week", int64(), us_week_doc,
                                     &default_us_week_options, WeekState::Init);
  DCHECK_OK(registry->AddFunction(std::move(us_week)));

  static const auto default_week_options = WeekOptions();
  auto week = UnaryTemporalFactory<Week, TemporalComponentExtractWeek, Int64Type>::Make<
      WithDates, WithTimestamps>("week", int64(), week_doc, &default_week_options,
                                 WeekState::Init);
  DCHECK_OK(registry->AddFunction(std::move(week)));

  auto iso_calendar =
      SimpleUnaryTemporalFactory<ISOCalendar>::Make<WithDates, WithTimestamps>(
          "iso_calendar", IsoCalendarType(), iso_calendar_doc);
  DCHECK_OK(registry->AddFunction(std::move(iso_calendar)));

  auto quarter =
      UnaryTemporalFactory<Quarter, TemporalComponentExtract,
                           Int64Type>::Make<WithDates, WithTimestamps>("quarter", int64(),
                                                                       quarter_doc);
  DCHECK_OK(registry->AddFunction(std::move(quarter)));

  // Date / time extractors
  auto hour =
      UnaryTemporalFactory<Hour, TemporalComponentExtract,
                           Int64Type>::Make<WithTimes, WithTimestamps>("hour", int64(),
                                                                       hour_doc);
  DCHECK_OK(registry->AddFunction(std::move(hour)));

  auto minute =
      UnaryTemporalFactory<Minute, TemporalComponentExtract,
                           Int64Type>::Make<WithTimes, WithTimestamps>("minute", int64(),
                                                                       minute_doc);
  DCHECK_OK(registry->AddFunction(std::move(minute)));

  auto second =
      UnaryTemporalFactory<Second, TemporalComponentExtract,
                           Int64Type>::Make<WithTimes, WithTimestamps>("second", int64(),
                                                                       second_doc);
  DCHECK_OK(registry->AddFunction(std::move(second)));

  auto millisecond =
      UnaryTemporalFactory<Millisecond, TemporalComponentExtract,
                           Int64Type>::Make<WithTimes, WithTimestamps>("millisecond",
                                                                       int64(),
                                                                       millisecond_doc);
  DCHECK_OK(registry->AddFunction(std::move(millisecond)));

  auto microsecond =
      UnaryTemporalFactory<Microsecond, TemporalComponentExtract,
                           Int64Type>::Make<WithTimes, WithTimestamps>("microsecond",
                                                                       int64(),
                                                                       microsecond_doc);
  DCHECK_OK(registry->AddFunction(std::move(microsecond)));

  auto nanosecond =
      UnaryTemporalFactory<Nanosecond, TemporalComponentExtract,
                           Int64Type>::Make<WithTimes, WithTimestamps>("nanosecond",
                                                                       int64(),
                                                                       nanosecond_doc);
  DCHECK_OK(registry->AddFunction(std::move(nanosecond)));

  auto subsecond =
      UnaryTemporalFactory<Subsecond, TemporalComponentExtract,
                           DoubleType>::Make<WithTimes, WithTimestamps>("subsecond",
                                                                        float64(),
                                                                        subsecond_doc);
  DCHECK_OK(registry->AddFunction(std::move(subsecond)));

  // Timezone-related functions
  static const auto default_strftime_options = StrftimeOptions();
  auto strftime =
      SimpleUnaryTemporalFactory<Strftime>::Make<WithTimes, WithDates, WithTimestamps>(
          "strftime", utf8(), strftime_doc, &default_strftime_options,
          StrftimeState::Init);
  DCHECK_OK(registry->AddFunction(std::move(strftime)));

  auto strptime = SimpleUnaryTemporalFactory<Strptime>::Make<WithStringTypes>(
      "strptime", OutputType::Resolver(ResolveStrptimeOutput), strptime_doc, nullptr,
      StrptimeState::Init, NullHandling::COMPUTED_PREALLOCATE);
  DCHECK_OK(registry->AddFunction(std::move(strptime)));

  auto assume_timezone =
      UnaryTemporalFactory<AssumeTimezone, AssumeTimezoneExtractor, TimestampType>::Make<
          WithTimestamps>("assume_timezone",
                          OutputType::Resolver(ResolveAssumeTimezoneOutput),
                          assume_timezone_doc, nullptr, AssumeTimezoneState::Init);
  DCHECK_OK(registry->AddFunction(std::move(assume_timezone)));

  auto is_dst =
      UnaryTemporalFactory<IsDaylightSavings, DaylightSavingsExtractor,
                           BooleanType>::Make<WithTimestamps>("is_dst", boolean(),
                                                              is_dst_doc);
  DCHECK_OK(registry->AddFunction(std::move(is_dst)));

  auto local_timestamp =
      UnaryTemporalFactory<LocalTimestamp, TemporalComponentExtract, TimestampType>::Make<
          WithTimestamps>("local_timestamp",
                          OutputType::Resolver(ResolveLocalTimestampOutput),
                          local_timestamp_doc);
  DCHECK_OK(registry->AddFunction(std::move(local_timestamp)));

  // Temporal rounding functions
  // Note: UnaryTemporalFactory will not correctly resolve OutputType(FirstType) to
  // output type. See TemporalComponentExtractRound for more.

  static const auto default_round_temporal_options = RoundTemporalOptions::Defaults();
  auto floor_temporal = UnaryTemporalFactory<FloorTemporal, TemporalComponentExtractRound,
                                             TimestampType>::Make<WithDates, WithTimes,
                                                                  WithTimestamps>(
      "floor_temporal", OutputType(FirstType), floor_temporal_doc,
      &default_round_temporal_options, RoundTemporalState::Init);
  DCHECK_OK(registry->AddFunction(std::move(floor_temporal)));
  auto ceil_temporal = UnaryTemporalFactory<CeilTemporal, TemporalComponentExtractRound,
                                            TimestampType>::Make<WithDates, WithTimes,
                                                                 WithTimestamps>(
      "ceil_temporal", OutputType(FirstType), ceil_temporal_doc,
      &default_round_temporal_options, RoundTemporalState::Init);
  DCHECK_OK(registry->AddFunction(std::move(ceil_temporal)));
  auto round_temporal = UnaryTemporalFactory<RoundTemporal, TemporalComponentExtractRound,
                                             TimestampType>::Make<WithDates, WithTimes,
                                                                  WithTimestamps>(
      "round_temporal", OutputType(FirstType), round_temporal_doc,
      &default_round_temporal_options, RoundTemporalState::Init);
  DCHECK_OK(registry->AddFunction(std::move(round_temporal)));
}