[evolution] Bug 341348 - Interpret date-only dates in calendar:// URL as in the local zone



commit 89be8b73ae2a3c848711002ee4b4bc78ec4c9462
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jun 15 13:00:50 2015 +0200

    Bug 341348 - Interpret date-only dates in calendar:// URL as in the local zone

 modules/calendar/e-cal-base-shell-backend.c |   25 +++++++++++++++++++++++--
 modules/calendar/e-cal-shell-backend.c      |    2 +-
 2 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/modules/calendar/e-cal-base-shell-backend.c b/modules/calendar/e-cal-base-shell-backend.c
index 7589d18..c8b4e8b 100644
--- a/modules/calendar/e-cal-base-shell-backend.c
+++ b/modules/calendar/e-cal-base-shell-backend.c
@@ -404,6 +404,27 @@ populate_g_date (GDate *date,
        g_date_set_dmy (date, icaltm.day, icaltm.month, icaltm.year);
 }
 
+static time_t
+convert_time_from_isodate (const gchar *text,
+                          icaltimezone *use_date_zone)
+{
+       time_t res;
+
+       g_return_val_if_fail (text != NULL, (time_t) 0);
+
+       res = time_from_isodate (text);
+
+       /* Is it date only? Then use the date zone to match the right day */
+       if (use_date_zone && strlen (text) == 8) {
+               struct icaltimetype itt;
+
+               itt = icaltime_from_timet (res, TRUE);
+               res = icaltime_as_timet_with_zone (itt, use_date_zone);
+       }
+
+       return res;
+}
+
 gboolean
 e_cal_base_shell_backend_util_handle_uri (EShellBackend *shell_backend,
                                          ECalClientSourceType source_type,
@@ -497,9 +518,9 @@ e_cal_base_shell_backend_util_handle_uri (EShellBackend *shell_backend,
 
                content = g_strndup (cp, content_len);
                if (g_ascii_strcasecmp (header, "startdate") == 0)
-                       populate_g_date (&start_date, time_from_isodate (content), zone);
+                       populate_g_date (&start_date, convert_time_from_isodate (content, zone), zone);
                else if (g_ascii_strcasecmp (header, "enddate") == 0)
-                       populate_g_date (&end_date, time_from_isodate (content) - 1, zone);
+                       populate_g_date (&end_date, convert_time_from_isodate (content, zone) - 1, zone);
                else if (g_ascii_strcasecmp (header, "source-uid") == 0)
                        source_uid = g_strdup (content);
                else if (g_ascii_strcasecmp (header, "comp-uid") == 0)
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index e3d33f0..f2a22c9 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -152,7 +152,7 @@ cal_shell_backend_handle_uri_start_end_dates (EShellBackend *shell_backend,
        if (g_date_valid (end_date))
                e_cal_shell_backend_open_date_range (E_CAL_SHELL_BACKEND (shell_backend), start_date, 
end_date);
        else
-               e_cal_shell_backend_open_date_range (E_CAL_SHELL_BACKEND (shell_backend), start_date, NULL);
+               e_cal_shell_backend_open_date_range (E_CAL_SHELL_BACKEND (shell_backend), start_date, 
start_date);
 }
 
 static gboolean


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