From 1c5b826af020a202c2e492666d567c90ec770ab3 Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Mon, 21 Sep 2026 12:32:38 -0400 Subject: [PATCH] gui/window: Only enable "win.today" action on the current day Fixes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/work_items/1021 Fixes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/work_items/1066 Part-of: --- src/gui/gcal-window.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/gcal-window.c b/src/gui/gcal-window.c index d30a123e..fcd27e99 100644 --- a/src/gui/gcal-window.c +++ b/src/gui/gcal-window.c @@ -190,6 +190,12 @@ update_today_action_enabled (GcalWindow *window) g_autoptr (GDateTime) now = NULL; GSimpleAction *action; gboolean enabled; + int active_year; + int active_month; + int active_day; + int now_year; + int now_month; + int now_day; GCAL_ENTRY; @@ -200,12 +206,13 @@ update_today_action_enabled (GcalWindow *window) case GCAL_WINDOW_VIEW_WEEK: case GCAL_WINDOW_VIEW_MONTH: case GCAL_WINDOW_VIEW_AGENDA: - enabled = g_date_time_get_year (window->active_date) != g_date_time_get_year (now) || - g_date_time_get_week_of_year (window->active_date) != g_date_time_get_week_of_year (now); + g_date_time_get_ymd (window->active_date, &active_year, &active_month, &active_day); + g_date_time_get_ymd (now, &now_year, &now_month, &now_day); - GCAL_TRACE_MSG ("Active date's week is %d, current week is %d", - g_date_time_get_week_of_year (window->active_date), - g_date_time_get_week_of_year (now)); + enabled = active_year != now_year || active_month != now_month || active_day != now_day; + + GCAL_TRACE_MSG ("Active date's year, month, and day are %d, %d, and %d; current year, month, and day are %d, %d, %d", + active_year, active_month, active_day, now_year, now_month, now_day); break; default: