@@ -332,6 +332,8 @@ G_BEGIN_DECLS
332332 * #GArrowTrimOptions is a class to customize the `utf8_trim`, `utf8_ltrim`,
333333 * `utf8_rtrim`, `ascii_trim`, `ascii_ltrim`, and `ascii_rtrim` functions.
334334 *
335+ * #GArrowWeekOptions is a class to customize the `week` function.
336+ *
335337 * There are many functions to compute data on an array.
336338 */
337339
@@ -9310,7 +9312,7 @@ garrow_round_temporal_options_class_init(GArrowRoundTemporalOptionsClass *klass)
93109312 */
93119313 spec =
93129314 g_param_spec_boolean (" week-starts-monday" ,
9313- " Week Starts Monday" ,
9315+ " Week starts Monday" ,
93149316 " What day does the week start with (Monday=true, Sunday=false)" ,
93159317 options.week_starts_monday ,
93169318 static_cast <GParamFlags>(G_PARAM_READWRITE));
@@ -10088,6 +10090,148 @@ garrow_trim_options_new(void)
1008810090 return GARROW_TRIM_OPTIONS (g_object_new (GARROW_TYPE_TRIM_OPTIONS, nullptr ));
1008910091}
1009010092
10093+ enum {
10094+ PROP_WEEK_OPTIONS_WEEK_STARTS_MONDAY = 1 ,
10095+ PROP_WEEK_OPTIONS_COUNT_FROM_ZERO,
10096+ PROP_WEEK_OPTIONS_FIRST_WEEK_IS_FULLY_IN_YEAR,
10097+ };
10098+
10099+ G_DEFINE_TYPE (GArrowWeekOptions, garrow_week_options, GARROW_TYPE_FUNCTION_OPTIONS)
10100+
10101+ static void
10102+ garrow_week_options_set_property(GObject *object,
10103+ guint prop_id,
10104+ const GValue *value,
10105+ GParamSpec *pspec)
10106+ {
10107+ auto options = garrow_week_options_get_raw (GARROW_WEEK_OPTIONS (object));
10108+
10109+ switch (prop_id) {
10110+ case PROP_WEEK_OPTIONS_WEEK_STARTS_MONDAY:
10111+ options->week_starts_monday = g_value_get_boolean (value);
10112+ break ;
10113+ case PROP_WEEK_OPTIONS_COUNT_FROM_ZERO:
10114+ options->count_from_zero = g_value_get_boolean (value);
10115+ break ;
10116+ case PROP_WEEK_OPTIONS_FIRST_WEEK_IS_FULLY_IN_YEAR:
10117+ options->first_week_is_fully_in_year = g_value_get_boolean (value);
10118+ break ;
10119+ default :
10120+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
10121+ break ;
10122+ }
10123+ }
10124+
10125+ static void
10126+ garrow_week_options_get_property (GObject *object,
10127+ guint prop_id,
10128+ GValue *value,
10129+ GParamSpec *pspec)
10130+ {
10131+ auto options = garrow_week_options_get_raw (GARROW_WEEK_OPTIONS (object));
10132+
10133+ switch (prop_id) {
10134+ case PROP_WEEK_OPTIONS_WEEK_STARTS_MONDAY:
10135+ g_value_set_boolean (value, options->week_starts_monday );
10136+ break ;
10137+ case PROP_WEEK_OPTIONS_COUNT_FROM_ZERO:
10138+ g_value_set_boolean (value, options->count_from_zero );
10139+ break ;
10140+ case PROP_WEEK_OPTIONS_FIRST_WEEK_IS_FULLY_IN_YEAR:
10141+ g_value_set_boolean (value, options->first_week_is_fully_in_year );
10142+ break ;
10143+ default :
10144+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
10145+ break ;
10146+ }
10147+ }
10148+
10149+ static void
10150+ garrow_week_options_init (GArrowWeekOptions *object)
10151+ {
10152+ auto priv = GARROW_FUNCTION_OPTIONS_GET_PRIVATE (object);
10153+ priv->options =
10154+ static_cast <arrow::compute::FunctionOptions *>(new arrow::compute::WeekOptions ());
10155+ }
10156+
10157+ static void
10158+ garrow_week_options_class_init (GArrowWeekOptionsClass *klass)
10159+ {
10160+ auto gobject_class = G_OBJECT_CLASS (klass);
10161+
10162+ gobject_class->set_property = garrow_week_options_set_property;
10163+ gobject_class->get_property = garrow_week_options_get_property;
10164+
10165+ auto options = arrow::compute::WeekOptions::Defaults ();
10166+
10167+ GParamSpec *spec;
10168+ /* *
10169+ * GArrowWeekOptions:week-starts-monday:
10170+ *
10171+ * What day does the week start with (Monday=true, Sunday=false).
10172+ *
10173+ * Since: 23.0.0
10174+ */
10175+ spec =
10176+ g_param_spec_boolean (" week-starts-monday" ,
10177+ " Week starts Monday" ,
10178+ " What day does the week start with (Monday=true, Sunday=false)" ,
10179+ options.week_starts_monday ,
10180+ static_cast <GParamFlags>(G_PARAM_READWRITE));
10181+ g_object_class_install_property (gobject_class,
10182+ PROP_WEEK_OPTIONS_WEEK_STARTS_MONDAY,
10183+ spec);
10184+
10185+ /* *
10186+ * GArrowWeekOptions:count-from-zero:
10187+ *
10188+ * Dates from current year that fall into last ISO week of the previous year
10189+ * return 0 if true and 52 or 53 if false.
10190+ *
10191+ * Since: 23.0.0
10192+ */
10193+ spec = g_param_spec_boolean (" count-from-zero" ,
10194+ " Count from zero" ,
10195+ " Dates from current year that fall into last ISO week of "
10196+ " the previous year return 0 if true and 52 or 53 if false" ,
10197+ options.count_from_zero ,
10198+ static_cast <GParamFlags>(G_PARAM_READWRITE));
10199+ g_object_class_install_property (gobject_class, PROP_WEEK_OPTIONS_COUNT_FROM_ZERO, spec);
10200+
10201+ /* *
10202+ * GArrowWeekOptions:first-week-is-fully-in-year:
10203+ *
10204+ * Must the first week be fully in January (true), or is a week that begins
10205+ * on December 29, 30, or 31 considered to be the first week of the new
10206+ * year (false)?
10207+ *
10208+ * Since: 23.0.0
10209+ */
10210+ spec = g_param_spec_boolean (
10211+ " first-week-is-fully-in-year" ,
10212+ " First week is fully in year" ,
10213+ " Must the first week be fully in January (true), or is a week that begins on "
10214+ " December 29, 30, or 31 considered to be the first week of the new year (false)?" ,
10215+ options.first_week_is_fully_in_year ,
10216+ static_cast <GParamFlags>(G_PARAM_READWRITE));
10217+ g_object_class_install_property (gobject_class,
10218+ PROP_WEEK_OPTIONS_FIRST_WEEK_IS_FULLY_IN_YEAR,
10219+ spec);
10220+ }
10221+
10222+ /* *
10223+ * garrow_week_options_new:
10224+ *
10225+ * Returns: A newly created #GArrowWeekOptions.
10226+ *
10227+ * Since: 23.0.0
10228+ */
10229+ GArrowWeekOptions *
10230+ garrow_week_options_new (void )
10231+ {
10232+ return GARROW_WEEK_OPTIONS (g_object_new (GARROW_TYPE_WEEK_OPTIONS, nullptr ));
10233+ }
10234+
1009110235G_END_DECLS
1009210236
1009310237arrow::Result<arrow::FieldRef>
@@ -10353,6 +10497,11 @@ garrow_function_options_new_raw(const arrow::compute::FunctionOptions *arrow_opt
1035310497 static_cast <const arrow::compute::TrimOptions *>(arrow_options);
1035410498 auto options = garrow_trim_options_new_raw (arrow_trim_options);
1035510499 return GARROW_FUNCTION_OPTIONS (options);
10500+ } else if (arrow_type_name == " WeekOptions" ) {
10501+ const auto arrow_week_options =
10502+ static_cast <const arrow::compute::WeekOptions *>(arrow_options);
10503+ auto options = garrow_week_options_new_raw (arrow_week_options);
10504+ return GARROW_FUNCTION_OPTIONS (options);
1035610505 } else {
1035710506 auto options = g_object_new (GARROW_TYPE_FUNCTION_OPTIONS, NULL );
1035810507 return GARROW_FUNCTION_OPTIONS (options);
@@ -11430,3 +11579,24 @@ garrow_trim_options_get_raw(GArrowTrimOptions *options)
1143011579 return static_cast <arrow::compute::TrimOptions *>(
1143111580 garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
1143211581}
11582+
11583+ GArrowWeekOptions *
11584+ garrow_week_options_new_raw (const arrow::compute::WeekOptions *arrow_options)
11585+ {
11586+ auto options = g_object_new (GARROW_TYPE_WEEK_OPTIONS,
11587+ " week-starts-monday" ,
11588+ arrow_options->week_starts_monday ,
11589+ " count-from-zero" ,
11590+ arrow_options->count_from_zero ,
11591+ " first-week-is-fully-in-year" ,
11592+ arrow_options->first_week_is_fully_in_year ,
11593+ nullptr );
11594+ return GARROW_WEEK_OPTIONS (options);
11595+ }
11596+
11597+ arrow::compute::WeekOptions *
11598+ garrow_week_options_get_raw (GArrowWeekOptions *options)
11599+ {
11600+ return static_cast <arrow::compute::WeekOptions *>(
11601+ garrow_function_options_get_raw (GARROW_FUNCTION_OPTIONS (options)));
11602+ }
0 commit comments