From 0751c2e93caaefca15d88cb02334484306df5416 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 7 Dec 2021 12:34:14 -0300 Subject: [PATCH] event-editor/schedule-section: Show times in local timezone Preserve the original timezone when editing, but always display the start and end times in local timezone. --- src/gui/event-editor/gcal-schedule-section.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/event-editor/gcal-schedule-section.c b/src/gui/event-editor/gcal-schedule-section.c index a992dc78..cce6deaa 100644 --- a/src/gui/event-editor/gcal-schedule-section.c +++ b/src/gui/event-editor/gcal-schedule-section.c @@ -220,6 +220,7 @@ format_datetime_for_display (GDateTime *date, gboolean all_day) { g_autofree gchar *formatted_date = NULL; + g_autoptr (GDateTime) local_dt = NULL; g_autoptr (GDateTime) now = NULL; GString *string; gint days_diff; @@ -227,7 +228,8 @@ format_datetime_for_display (GDateTime *date, string = g_string_new (""); now = g_date_time_new_now_local (); - days_diff = gcal_date_time_compare_date (date, now); + local_dt = all_day ? g_date_time_ref (date) : g_date_time_to_local (date); + days_diff = gcal_date_time_compare_date (local_dt, now); switch (days_diff) { @@ -238,7 +240,7 @@ format_datetime_for_display (GDateTime *date, case -3: case -2: /* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */ - formatted_date = g_date_time_format (date, _("Last %A")); + formatted_date = g_date_time_format (local_dt, _("Last %A")); break; case -1: @@ -260,11 +262,11 @@ format_datetime_for_display (GDateTime *date, case 6: case 7: /* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */ - formatted_date = g_date_time_format (date, _("This %A")); + formatted_date = g_date_time_format (local_dt, _("This %A")); break; default: - formatted_date = g_date_time_format (date, "%x"); + formatted_date = g_date_time_format (local_dt, "%x"); break; } @@ -275,11 +277,11 @@ format_datetime_for_display (GDateTime *date, switch (format) { case GCAL_TIME_FORMAT_12H: - formatted_time = g_date_time_format (date, "%I:%M %P"); + formatted_time = g_date_time_format (local_dt, "%I:%M %P"); break; case GCAL_TIME_FORMAT_24H: - formatted_time = g_date_time_format (date, "%R"); + formatted_time = g_date_time_format (local_dt, "%R"); break; default: