@@ -333,6 +333,8 @@ G_BEGIN_DECLS
333333 * #GArrowTrimOptions is a class to customize the `utf8_trim`, `utf8_ltrim`,
334334 * `utf8_rtrim`, `ascii_trim`, `ascii_ltrim`, and `ascii_rtrim` functions.
335335 *
336+ * #GArrowWeekOptions is a class to customize the `week` function.
337+ *
336338 * There are many functions to compute data on an array.
337339 */
338340
@@ -10315,6 +10317,140 @@ garrow_trim_options_new(void)
1031510317 return GARROW_TRIM_OPTIONS (g_object_new (GARROW_TYPE_TRIM_OPTIONS, NULL ));
1031610318}
1031710319
10320+ enum {
10321+ PROP_WEEK_OPTIONS_WEEK_STARTS_MONDAY = 1 ,
10322+ PROP_WEEK_OPTIONS_COUNT_FROM_ZERO,
10323+ PROP_WEEK_OPTIONS_FIRST_WEEK_IS_FULLY_IN_YEAR,
10324+ };
10325+
10326+ G_DEFINE_TYPE (GArrowWeekOptions, garrow_week_options, GARROW_TYPE_FUNCTION_OPTIONS)
10327+
10328+ static void
10329+ garrow_week_options_set_property(GObject *object,
10330+ guint prop_id,
10331+ const GValue *value,
10332+ GParamSpec *pspec)
10333+ {
10334+ auto options = garrow_week_options_get_raw (GARROW_WEEK_OPTIONS (object));
10335+
10336+ switch (prop_id) {
10337+ case PROP_WEEK_OPTIONS_WEEK_STARTS_MONDAY:
10338+ options->week_starts_monday = g_value_get_boolean (value);
10339+ break ;
10340+ case PROP_WEEK_OPTIONS_COUNT_FROM_ZERO:
10341+ options->count_from_zero = g_value_get_boolean (value);
10342+ break ;
10343+ case PROP_WEEK_OPTIONS_FIRST_WEEK_IS_FULLY_IN_YEAR:
10344+ options->first_week_is_fully_in_year = g_value_get_boolean (value);
10345+ break ;
10346+ default :
10347+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
10348+ break ;
10349+ }
10350+ }
10351+
10352+ static void
10353+ garrow_week_options_get_property (GObject *object,
10354+ guint prop_id,
10355+ GValue *value,
10356+ GParamSpec *pspec)
10357+ {
10358+ auto options = garrow_week_options_get_raw (GARROW_WEEK_OPTIONS (object));
10359+
10360+ switch (prop_id) {
10361+ case PROP_WEEK_OPTIONS_WEEK_STARTS_MONDAY:
10362+ g_value_set_boolean (value, options->week_starts_monday );
10363+ break ;
10364+ case PROP_WEEK_OPTIONS_COUNT_FROM_ZERO:
10365+ g_value_set_boolean (value, options->count_from_zero );
10366+ break ;
10367+ case PROP_WEEK_OPTIONS_FIRST_WEEK_IS_FULLY_IN_YEAR:
10368+ g_value_set_boolean (value, options->first_week_is_fully_in_year );
10369+ break ;
10370+ default :
10371+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
10372+ break ;
10373+ }
10374+ }
10375+
10376+ static void
10377+ garrow_week_options_init (GArrowWeekOptions *object)
10378+ {
10379+ auto priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
10380+ priv->options =
10381+ static_cast <arrow::compute::FunctionOptions *>(new arrow::compute::WeekOptions ());
10382+ }
10383+
10384+ static void
10385+ garrow_week_options_class_init (GArrowWeekOptionsClass *klass)
10386+ {
10387+ auto gobject_class = G_OBJECT_CLASS (klass);
10388+
10389+ gobject_class->set_property = garrow_week_options_set_property;
10390+ gobject_class->get_property = garrow_week_options_get_property;
10391+
10392+ auto options = arrow::compute::WeekOptions::Defaults ();
10393+
10394+ GParamSpec *spec;
10395+ /* *
10396+ * GArrowWeekOptions:week-starts-monday:
10397+ *
10398+ * What day does the week start with (Monday=true, Sunday=false).
10399+ *
10400+ * Since: 23.0.0
10401+ */
10402+ spec = g_param_spec_boolean (" week-starts-monday" ,
10403+ " Week starts Monday" ,
10404+ " What day does the week start with (Monday=true, Sunday=false)" ,
10405+ options.week_starts_monday ,
10406+ static_cast <GParamFlags>(G_PARAM_READWRITE));
10407+ g_object_class_install_property (gobject_class, PROP_WEEK_OPTIONS_WEEK_STARTS_MONDAY, spec);
10408+
10409+ /* *
10410+ * GArrowWeekOptions:count-from-zero:
10411+ *
10412+ * Dates from current year that fall into last ISO week of the previous year
10413+ * return 0 if true and 52 or 53 if false.
10414+ *
10415+ * Since: 23.0.0
10416+ */
10417+ spec = g_param_spec_boolean (" count-from-zero" ,
10418+ " Count from zero" ,
10419+ " Dates from current year that fall into last ISO week of the previous year return 0 if true and 52 or 53 if false" ,
10420+ options.count_from_zero ,
10421+ static_cast <GParamFlags>(G_PARAM_READWRITE));
10422+ g_object_class_install_property (gobject_class, PROP_WEEK_OPTIONS_COUNT_FROM_ZERO, spec);
10423+
10424+ /* *
10425+ * GArrowWeekOptions:first-week-is-fully-in-year:
10426+ *
10427+ * Must the first week be fully in January (true), or is a week that begins
10428+ * on December 29, 30, or 31 considered to be the first week of the new
10429+ * year (false)?
10430+ *
10431+ * Since: 23.0.0
10432+ */
10433+ spec = g_param_spec_boolean (" first-week-is-fully-in-year" ,
10434+ " First week is fully in year" ,
10435+ " Must the first week be fully in January (true), or is a week that begins on December 29, 30, or 31 considered to be the first week of the new year (false)?" ,
10436+ options.first_week_is_fully_in_year ,
10437+ static_cast <GParamFlags>(G_PARAM_READWRITE));
10438+ g_object_class_install_property (gobject_class, PROP_WEEK_OPTIONS_FIRST_WEEK_IS_FULLY_IN_YEAR, spec);
10439+ }
10440+
10441+ /* *
10442+ * garrow_week_options_new:
10443+ *
10444+ * Returns: A newly created #GArrowWeekOptions.
10445+ *
10446+ * Since: 23.0.0
10447+ */
10448+ GArrowWeekOptions *
10449+ garrow_week_options_new (void )
10450+ {
10451+ return GARROW_WEEK_OPTIONS (g_object_new (GARROW_TYPE_WEEK_OPTIONS, NULL ));
10452+ }
10453+
1031810454G_END_DECLS
1031910455
1032010456arrow::Result<arrow::FieldRef>
@@ -10586,6 +10722,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
1058610722 static_cast <const arrow::compute::TrimOptions *>(arrow_options);
1058710723 auto options = garrow_trim_options_new_raw (arrow_trim_options);
1058810724 return GARROW_FUNCTION_OPTIONS (options);
10725+ } else if (arrow_type_name == " WeekOptions" ) {
10726+ const auto arrow_week_options =
10727+ static_cast <const arrow::compute::WeekOptions *>(arrow_options);
10728+ auto options = garrow_week_options_new_raw (arrow_week_options);
10729+ return GARROW_FUNCTION_OPTIONS (options);
1058910730 } else {
1059010731 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
1059110732 return GARROW_FUNCTION_OPTIONS (options);
@@ -11691,3 +11832,24 @@ garrow_trim_options_get_raw(GArrowTrimOptions *options)
1169111832 return static_cast <arrow::compute::TrimOptions *>(
1169211833 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
1169311834}
11835+
11836+ GArrowWeekOptions *
11837+ garrow_week_options_new_raw (const arrow::compute::WeekOptions *arrow_options)
11838+ {
11839+ auto options = g_object_new (GARROW_TYPE_WEEK_OPTIONS,
11840+ " week-starts-monday" ,
11841+ arrow_options->week_starts_monday ,
11842+ " count-from-zero" ,
11843+ arrow_options->count_from_zero ,
11844+ " first-week-is-fully-in-year" ,
11845+ arrow_options->first_week_is_fully_in_year ,
11846+ NULL );
11847+ return GARROW_WEEK_OPTIONS (options);
11848+ }
11849+
11850+ arrow::compute::WeekOptions *
11851+ garrow_week_options_get_raw (GArrowWeekOptions *options)
11852+ {
11853+ return static_cast <arrow::compute::WeekOptions *>(
11854+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
11855+ }
0 commit comments