[california] Fix timezone issue related to event time spans



commit 71bacb4e6acd159e44b6a9a8e21769c8473849a9
Author: Jim Nelson <jim yorba org>
Date:   Fri Mar 21 17:48:07 2014 -0700

    Fix timezone issue related to event time spans
    
    When determining what date to place an Event into, the time span was
    not being converted to local time.

 src/calendar/calendar-exact-time.vala  |    2 +-
 src/component/component-event.vala     |    8 ++++++--
 src/host/host-show-event.vala          |    2 +-
 src/view/month/month-cell.vala         |    2 +-
 src/view/month/month-controllable.vala |    4 ++--
 5 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/calendar/calendar-exact-time.vala b/src/calendar/calendar-exact-time.vala
index 518a2dc..129a835 100644
--- a/src/calendar/calendar-exact-time.vala
+++ b/src/calendar/calendar-exact-time.vala
@@ -210,7 +210,7 @@ public class ExactTime : BaseObject, Gee.Comparable<ExactTime>, Gee.Hashable<Exa
     }
     
     public override string to_string() {
-        return date_time.to_string();
+        return "%s/%s".printf(date_time.to_string(), tz.to_string());
     }
 }
 
diff --git a/src/component/component-event.vala b/src/component/component-event.vala
index 3aea5fd..83930dc 100644
--- a/src/component/component-event.vala
+++ b/src/component/component-event.vala
@@ -162,8 +162,12 @@ public class Event : Instance, Gee.Comparable<Event> {
      *
      * This will return a DateSpan whether the Event is a DATE or DATE-TIME VEVENT.
      */
-    public Calendar.DateSpan get_event_date_span() {
-        return date_span ?? new Calendar.DateSpan.from_exact_time_span(exact_time_span);
+    public Calendar.DateSpan get_event_date_span(Calendar.Timezone? tz) {
+        if (date_span != null)
+            return date_span;
+        
+        return new Calendar.DateSpan.from_exact_time_span(
+            tz != null ? exact_time_span.to_timezone(tz) : exact_time_span);
     }
     
     /**
diff --git a/src/host/host-show-event.vala b/src/host/host-show-event.vala
index 1c8af92..60ac876 100644
--- a/src/host/host-show-event.vala
+++ b/src/host/host-show-event.vala
@@ -56,7 +56,7 @@ public class ShowEvent : Gtk.Grid, Interaction {
         
         // if any dates are not in current year, display year in all dates
         Calendar.Date.PrettyFlag date_flags = Calendar.Date.PrettyFlag.NONE;
-        Calendar.DateSpan date_span = event.get_event_date_span();
+        Calendar.DateSpan date_span = event.get_event_date_span(Calendar.Timezone.local);
         if (!date_span.start_date.year.equal_to(Calendar.System.today.year)
             || !date_span.end_date.year.equal_to(Calendar.System.today.year)) {
             date_flags |= Calendar.Date.PrettyFlag.INCLUDE_YEAR;
diff --git a/src/view/month/month-cell.vala b/src/view/month/month-cell.vala
index fd470e9..dd1ee0f 100644
--- a/src/view/month/month-cell.vala
+++ b/src/view/month/month-cell.vala
@@ -175,7 +175,7 @@ public class Cell : Gtk.EventBox {
         
         // remove from cell if no longer in this day, otherwise remove and add again to days_events
         // to re-sort
-        if (!(date in event.get_event_date_span()))
+        if (!(date in event.get_event_date_span(Calendar.Timezone.local)))
             remove_event(event);
         else if (days_events.remove(event))
             days_events.add(event);
diff --git a/src/view/month/month-controllable.vala b/src/view/month/month-controllable.vala
index 2ec0780..6528522 100644
--- a/src/view/month/month-controllable.vala
+++ b/src/view/month/month-controllable.vala
@@ -311,7 +311,7 @@ public class Controllable : Gtk.Grid, View.Controllable {
             return;
         
         // add event to every date it represents
-        foreach (Calendar.Date date in event.get_event_date_span()) {
+        foreach (Calendar.Date date in event.get_event_date_span(Calendar.Timezone.local)) {
             Cell? cell = date_to_cell.get(date);
             if (cell != null)
                 cell.add_event(event);
@@ -323,7 +323,7 @@ public class Controllable : Gtk.Grid, View.Controllable {
         if (event == null)
             return;
         
-        foreach (Calendar.Date date in event.get_event_date_span()) {
+        foreach (Calendar.Date date in event.get_event_date_span(Calendar.Timezone.local)) {
             Cell? cell = date_to_cell.get(date);
             if (cell != null)
                 cell.remove_event(event);


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