[gnome-calendar/gbsneto/timezone-fixes: 3/3] event-editor/schedule-section: Show times in local timezone
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gbsneto/timezone-fixes: 3/3] event-editor/schedule-section: Show times in local timezone
- Date: Tue, 7 Dec 2021 15:39:01 +0000 (UTC)
commit 8cfc42cf2af07dc4dec3ed93deb0938906359d9e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Dec 7 12:34:14 2021 -0300
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..3c6e9c66 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 = 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:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]