diff options
author | Michael Catanzaro <mcatanzaro@igalia.com> | 2017-12-05 16:28:18 -0600 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@posteo.net> | 2018-03-18 00:03:03 +0000 |
commit | d04a603472a2467e5cb75b03114e51f91e12d3f6 (patch) | |
tree | 04f78640ce50a5f65d73a06ef1590d67e1d7ee3c | |
parent | cf5cc7dfdfc2184209bdd2993f60fb49b1e0cefe (diff) | |
download | gnome-calendar-cherry-pick-ce8e8c21.tar.gz |
edit-dialog: Fix timezone for events created in month viewcherry-pick-ce8e8c21
In month view, when clicking on a day of the month, every event is
initially an All Day event until the user opens the Edit Details dialog
and unchecks the checkbox. This means that the event is originally
created in UTC time, and needs to be explicitly switched to local time.
(cherry picked from commit ce8e8c217eaa299c13365728a25fe5466969a871)
-rw-r--r-- | src/gcal-edit-dialog.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c index 359b94a0..fbba3a1c 100644 --- a/src/gcal-edit-dialog.c +++ b/src/gcal-edit-dialog.c @@ -452,6 +452,7 @@ action_button_clicked (GtkWidget *widget, GcalRecurrenceFrequency freq; GcalRecurrence *old_recur; GDateTime *start_date, *end_date; + gboolean was_all_day; gboolean all_day; gchar *note_text; @@ -468,6 +469,7 @@ action_button_clicked (GtkWidget *widget, /* Update all day */ all_day = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->all_day_check)); + was_all_day = gcal_event_get_all_day (dialog->event); gcal_event_set_all_day (dialog->event, all_day); @@ -483,7 +485,7 @@ action_button_clicked (GtkWidget *widget, /* * Update start & end dates. The dates are already translated to the current - * timezone. + * timezone (unless the event used to be all day, but no longer is). */ start_date = gcal_edit_dialog_get_date_start (dialog); end_date = gcal_edit_dialog_get_date_end (dialog); @@ -500,6 +502,23 @@ action_button_clicked (GtkWidget *widget, g_clear_pointer (&end_date, g_date_time_unref); end_date = fake_end_date; } + else if (!all_day && was_all_day) + { + /* When an all day event is changed to be not an all day event, we + * need to correct for the fact that the event's timezone was until + * now set to UTC. That means we need to change the timezone to + * localtime now, or else it will be saved incorrectly. + */ + GDateTime *localtime_date; + + localtime_date = g_date_time_to_local (start_date); + g_clear_pointer (&start_date, g_date_time_unref); + start_date = localtime_date; + + localtime_date = g_date_time_to_local (end_date); + g_clear_pointer (&end_date, g_date_time_unref); + end_date = localtime_date; + } gcal_event_set_date_start (dialog->event, start_date); gcal_event_set_date_end (dialog->event, end_date); |