gcal_schedule_section_set_event(): Don't change the timezones when setting up the widgets

I think this was being done so that:

  - create a new all-day event
  - open it in the event editor
  - switch to time-slot
  - time choosers now say "UTC"

doesn't happen.  I think this can be handled more gracefully.

Evolution does not handle it very gracefully; when turning off
all-day in its event editor, it sets the times to $now.

The iOS calendar app is better.  If you turn all-day off, it picks
$next_hour_based_on_now for the start time, and $next_hour_plus_one
for the end time.  So if you turn off all-day and it is 18:24 right
now, it will set the start_time to 19:00 and the end_time to 20:00 ---
that is, it creates a one-hour event at the next start of the hour
from now.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/550>
This commit is contained in:
Federico Mena Quintero
2025-08-27 19:59:58 -03:00
committed by Georges Basile Stavracas Neto
parent 923424acab
commit 1309bf4a82
+4 -32
View File
@@ -445,10 +445,6 @@ gcal_schedule_section_set_event (GcalEventEditorSection *section,
GcalEvent *event,
GcalEventEditorFlags flags)
{
g_autoptr (GDateTime) date_time_start_utc = NULL;
g_autoptr (GDateTime) date_time_end_utc = NULL;
g_autoptr (GDateTime) date_time_start_local = NULL;
g_autoptr (GDateTime) date_time_end_local = NULL;
GcalScheduleSection *self;
GDateTime* date_time_start = NULL;
GDateTime* date_time_end = NULL;
@@ -488,41 +484,17 @@ gcal_schedule_section_set_event (GcalEventEditorSection *section,
*/
date_time_end = all_day ? g_date_time_add_days (date_time_end, -1) : date_time_end;
date_time_start_utc = g_date_time_new_utc (g_date_time_get_year (date_time_start),
g_date_time_get_month (date_time_start),
g_date_time_get_day_of_month (date_time_start),
0, 0, 0);
date_time_end_utc = g_date_time_new_utc (g_date_time_get_year (date_time_end),
g_date_time_get_month (date_time_end),
g_date_time_get_day_of_month (date_time_end),
0, 0, 0);
date_time_start_local = g_date_time_new_local (g_date_time_get_year (date_time_start),
g_date_time_get_month (date_time_start),
g_date_time_get_day_of_month (date_time_start),
g_date_time_get_hour (date_time_start),
g_date_time_get_minute (date_time_start),
0);
date_time_end_local = g_date_time_new_local (g_date_time_get_year (date_time_end),
g_date_time_get_month (date_time_end),
g_date_time_get_day_of_month (date_time_end),
g_date_time_get_hour (date_time_end),
g_date_time_get_minute (date_time_end),
0);
block_date_signals (self);
/* date */
gcal_date_chooser_row_set_date (self->start_date_row, date_time_start_utc);
gcal_date_chooser_row_set_date (self->end_date_row, date_time_end_utc);
gcal_date_chooser_row_set_date (self->start_date_row, date_time_start);
gcal_date_chooser_row_set_date (self->end_date_row, date_time_end);
/* date-time */
if (new_event || all_day)
{
gcal_date_time_chooser_set_date_time (self->start_date_time_chooser, date_time_start_local);
gcal_date_time_chooser_set_date_time (self->end_date_time_chooser, date_time_end_local);
gcal_date_time_chooser_set_date_time (self->start_date_time_chooser, date_time_start);
gcal_date_time_chooser_set_date_time (self->end_date_time_chooser, date_time_end);
}
else
{