utils: Align GcalWeekDay enum with ISO 8601

Start the enum from Monday-Sunday (1-7). Adapt code that references the
`is_workday()` utility method, which in turn uses the GcalWeekDay enum
to combine pairs of days by bitwise or-ing.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/822>
This commit is contained in:
mindonwarp
2026-09-26 17:21:57 +00:00
committed by Marge Bot
parent 2ef27531f4
commit c0a74ed76f
3 changed files with 10 additions and 10 deletions
+7 -7
View File
@@ -51,13 +51,13 @@ typedef enum
typedef enum
{
GCAL_WEEK_DAY_INVALID = 0,
GCAL_WEEK_DAY_SUNDAY = 1 << 0,
GCAL_WEEK_DAY_MONDAY = 1 << 1,
GCAL_WEEK_DAY_TUESDAY = 1 << 2,
GCAL_WEEK_DAY_WEDNESDAY = 1 << 3,
GCAL_WEEK_DAY_THURSDAY = 1 << 4,
GCAL_WEEK_DAY_FRIDAY = 1 << 5,
GCAL_WEEK_DAY_SATURDAY = 1 << 6
GCAL_WEEK_DAY_MONDAY = 1 << 0,
GCAL_WEEK_DAY_TUESDAY = 1 << 1,
GCAL_WEEK_DAY_WEDNESDAY = 1 << 2,
GCAL_WEEK_DAY_THURSDAY = 1 << 3,
GCAL_WEEK_DAY_FRIDAY = 1 << 4,
GCAL_WEEK_DAY_SATURDAY = 1 << 5,
GCAL_WEEK_DAY_SUNDAY = 1 << 6
} GcalWeekDay;
typedef enum
+1 -1
View File
@@ -199,7 +199,7 @@ gcal_date_chooser_day_set_date (GcalDateChooserDay *self,
now = g_date_time_new_now (g_date_time_get_timezone (date));
today = gcal_date_time_compare_date (date, now) == 0;
weekday = g_date_time_get_day_of_week (date) % GCAL_N_WEEKDAYS;
weekday = g_date_time_get_day_of_week (date);
if (G_UNLIKELY (today))
gtk_widget_add_css_class (widget, "today");
+2 -2
View File
@@ -549,7 +549,7 @@ struct
/**
* gcal_util_is_workday:
* @day: a guint representing the day of a week (0…Sunday, 6…Saturday)
* @day: a guint representing the ISO 8601 day of a week (1…Monday, 7…Sunday)
*
* Checks whether @day is workday or not based on the Territory part of Locale.
*
@@ -563,7 +563,7 @@ gcal_util_is_workday (guint day)
gchar territory[3] = { 0, };
guint i;
if (day > GCAL_N_WEEKDAYS - 1)
if (day < 1 || day > GCAL_N_WEEKDAYS)
return FALSE;
no_work_days = GCAL_WEEK_DAY_SATURDAY | GCAL_WEEK_DAY_SUNDAY;