[gnome-shell] Calendar: Fix UTC/local mixup



commit d9e778f501fa54bd3d886f4b984de0908a26235f
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Jan 31 11:49:02 2011 -0500

    Calendar: Fix UTC/local mixup
    
    See https://bugzilla.gnome.org/show_bug.cgi?id=632109#c56
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 src/shell-evolution-event-source.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/shell-evolution-event-source.c b/src/shell-evolution-event-source.c
index dd2aea9..2982ddc 100644
--- a/src/shell-evolution-event-source.c
+++ b/src/shell-evolution-event-source.c
@@ -99,7 +99,7 @@ shell_evolution_event_source_request_range (ShellEvolutionEventSource *source,
                                             gint64                     msec_begin,
                                             gint64                     msec_end)
 {
-  GDateTime *middle;
+  GDateTime *middle_utc, *middle;
 
   /* The CalendarClient type is a convenience wrapper on top of
    * Evolution Data Server. It is based on the assumption that only
@@ -112,7 +112,10 @@ shell_evolution_event_source_request_range (ShellEvolutionEventSource *source,
    * days before and after) it works out just fine.
    */
 
-  middle = g_date_time_new_from_unix_utc ((msec_begin + msec_end) / 2 / 1000);
+  middle_utc = g_date_time_new_from_unix_utc ((msec_begin + msec_end) / 2 / 1000);
+  /* CalendarClient uses localtime rather than UTC */
+  middle = g_date_time_to_local (middle_utc);
+  g_date_time_unref (middle_utc);
   g_date_time_get_ymd (middle, &source->req_year, &source->req_mon, NULL);
   g_date_time_unref (middle);
   calendar_client_select_month (source->client, source->req_mon - 1, source->req_year);
@@ -152,15 +155,22 @@ shell_evolution_event_source_get_events  (ShellEvolutionEventSource *source,
 {
   GList *result;
   GDateTime *cur_date;
-  GDateTime *begin_date;
-  GDateTime *end_date;
+  GDateTime *begin_date_utc, *begin_date;
+  GDateTime *end_date_utc, *end_date;
 
   g_return_val_if_fail (msec_begin <= msec_end, NULL);
 
   result = NULL;
 
-  begin_date = g_date_time_new_from_unix_utc (msec_begin / 1000);
-  end_date = g_date_time_new_from_unix_utc (msec_end / 1000);
+  begin_date_utc = g_date_time_new_from_unix_utc (msec_begin / 1000);
+  end_date_utc = g_date_time_new_from_unix_utc (msec_end / 1000);
+
+  /* CalendarClient uses localtime rather than UTC */
+  begin_date = g_date_time_to_local (begin_date_utc);
+  end_date = g_date_time_to_local (end_date_utc);
+  g_date_time_unref (begin_date_utc);
+  g_date_time_unref (end_date_utc);
+
   cur_date = g_date_time_ref (begin_date);
   do
     {



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