[gnome-calendar] event-popover: Fix popover for all-day multi-day events



commit c9fa9253c1e316926387df45a6c7019d5ab12ede
Author: Björn Daase <bjoern daase net>
Date:   Fri Feb 4 14:07:29 2022 +0100

    event-popover: Fix popover for all-day multi-day events
    
    All-day multi-day events go, e.g. from 01/01/2022 00:00 to 01/03/2022.
    The old logic would have shown January 1 - January 3. This, however, is
    incorrect and should instead be January 1 - January 2. As a result,
    subtract one day from the end date when in the all-day multi-day case.

 src/gui/gcal-event-popover.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/gui/gcal-event-popover.c b/src/gui/gcal-event-popover.c
index e6dc1006..d91c10da 100644
--- a/src/gui/gcal-event-popover.c
+++ b/src/gui/gcal-event-popover.c
@@ -379,10 +379,17 @@ update_date_time_label (GcalEventPopover *self)
       g_autofree gchar *start_str = NULL;
       g_autofree gchar *end_str = NULL;
       gboolean show_year;
+      g_autoptr (GDateTime) real_end_dt = NULL;
 
       show_year = g_date_time_get_year (start_dt) != g_date_time_get_year (end_dt);
       start_str = format_multiday_date (self, start_dt, show_year, show_hours);
-      end_str = format_multiday_date (self, end_dt, show_year, show_hours);
+
+      if (!show_hours)
+        real_end_dt = g_date_time_add_days (end_dt, -1);
+      else
+        real_end_dt = g_date_time_ref (end_dt);
+      
+      end_str = format_multiday_date (self, real_end_dt, show_year, show_hours);
 
       /* Translators: %1$s is the start date, and %2$s. For example: June 21 - November 29, 2022 */
       g_string_printf (string, _("%1$s — %2$s"), start_str, end_str);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]