viscal

cairo/gtk vi-like timeblocking calendar
git clone git://jb55.com/viscal
Log | Files | Refs | README | LICENSE

commit 1b002c7c91e0ccde1e44ef1f73e0ad37dd13e0f8
parent dfabe15b65cd42a1487ede4d580a2e7572ab73cc
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 15 Aug 2018 21:51:39 -0700

fix time calc

Diffstat:
Mviscal.c | 20+++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/viscal.c b/viscal.c @@ -606,11 +606,12 @@ calendar_time_to_loc(struct cal *cal, time_t time) { static void event_update (struct event *ev, struct cal *cal) { - icaltimetype evtime = icalcomponent_get_dtstart(ev->vevent); - icaltime_span span = icalcomponent_get_span(ev->vevent); - int isdate = evtime.is_date; + icaltimetype dtstart = icalcomponent_get_dtstart(ev->vevent); + icaltimetype dtend = icalcomponent_get_dtend(ev->vevent); + int isdate = dtstart.is_date; double sx, sy, y, eheight, height, width; + height = cal->height; width = cal->width; @@ -624,8 +625,12 @@ event_update (struct event *ev, struct cal *cal) y = EVPAD; } else { - double sloc = calendar_time_to_loc(cal, span.start); - double eloc = calendar_time_to_loc(cal, span.end); + // convert to local time + time_t st = icaltime_as_timet_with_zone(dtstart, dtstart.zone); + time_t et = icaltime_as_timet_with_zone(dtend, dtend.zone); + + double sloc = calendar_time_to_loc(cal, st); + double eloc = calendar_time_to_loc(cal, et); double dloc = eloc - sloc; eheight = dloc * height; @@ -740,6 +745,7 @@ draw_event (cairo_t *cr, struct cal *cal, struct event *ev) { icaltimetype dtstart = icalcomponent_get_dtstart(ev->vevent); icaltimetype dtend = icalcomponent_get_dtend(ev->vevent); int isdate = dtstart.is_date; + double x = ev->x; // TODO: date-event stacking double y = ev->y; @@ -749,8 +755,8 @@ draw_event (cairo_t *cr, struct cal *cal, struct event *ev) { dtstart.hour, dtstart.minute); - time_t st = icaltime_as_timet(dtstart); - time_t et = icaltime_as_timet(dtend); + time_t st = icaltime_as_timet_with_zone(dtstart, dtstart.zone); + time_t et = icaltime_as_timet_with_zone(dtend, dtend.zone); time_t len = et - st; cairo_text_extents_t exts;