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.
This commit is contained in:
Georges Basile Stavracas Neto
2021-12-07 13:32:16 -03:00
parent fc3ad22169
commit 0751c2e93c
+8 -6
View File
@@ -220,6 +220,7 @@ format_datetime_for_display (GDateTime *date,
gboolean all_day) gboolean all_day)
{ {
g_autofree gchar *formatted_date = NULL; g_autofree gchar *formatted_date = NULL;
g_autoptr (GDateTime) local_dt = NULL;
g_autoptr (GDateTime) now = NULL; g_autoptr (GDateTime) now = NULL;
GString *string; GString *string;
gint days_diff; gint days_diff;
@@ -227,7 +228,8 @@ format_datetime_for_display (GDateTime *date,
string = g_string_new (""); string = g_string_new ("");
now = g_date_time_new_now_local (); 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) switch (days_diff)
{ {
@@ -238,7 +240,7 @@ format_datetime_for_display (GDateTime *date,
case -3: case -3:
case -2: case -2:
/* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */ /* 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; break;
case -1: case -1:
@@ -260,11 +262,11 @@ format_datetime_for_display (GDateTime *date,
case 6: case 6:
case 7: case 7:
/* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */ /* 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; break;
default: default:
formatted_date = g_date_time_format (date, "%x"); formatted_date = g_date_time_format (local_dt, "%x");
break; break;
} }
@@ -275,11 +277,11 @@ format_datetime_for_display (GDateTime *date,
switch (format) switch (format)
{ {
case GCAL_TIME_FORMAT_12H: 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; break;
case GCAL_TIME_FORMAT_24H: case GCAL_TIME_FORMAT_24H:
formatted_time = g_date_time_format (date, "%R"); formatted_time = g_date_time_format (local_dt, "%R");
break; break;
default: default: