[gnome-calendar/cherry-pick-89e90fec] Merge branch 'wip/mcatanzaro/timezone' into 'master'
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/cherry-pick-89e90fec] Merge branch 'wip/mcatanzaro/timezone' into 'master'
- Date: Sat, 17 Mar 2018 23:52:20 +0000 (UTC)
commit e1010b7caa18689ba8204afb2583853c6011769c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Dec 6 10:45:42 2017 +0000
Merge branch 'wip/mcatanzaro/timezone' into 'master'
Events created in month or year view are created with incorrect time and missing timezone
Closes #168
See merge request GNOME/gnome-calendar!7
(cherry picked from commit 89e90fec6d01d538ede9a2764c29dae41daf506d)
ce8e8c21 edit-dialog: Fix timezone for events created in month view
1d8a1646 event: Fix changing the timezone
281ed44f Revert "event: correctly store timezones"
a7304ed9 event: Restore handling of all day events
0724d409 event: Save local time correctly
src/gcal-edit-dialog.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
---
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]