-/*
+ /*
* $Id$
*/
/**
struct icaltimetype end_t;
struct icaltimetype today_start_t;
struct icaltimetype today_end_t;
+ struct tm starting_tm;
+ struct tm ending_tm;
int all_day_event = 0;
int show_event = 0;
char buf[256];
}
/* Create an imaginary event which spans the 24 hours of today. Any events which
- * overlap with this one take place at least partially in this day.
+ * overlap with this one take place at least partially in this day. We have to
+ * convert it from a struct tm in order to make it UTC.
*/
- memset(&today_start_t, 0, sizeof today_start_t);
- today_start_t.year = year;
- today_start_t.month = month;
- today_start_t.day = day;
- today_start_t.hour = 0;
- today_start_t.minute = 0;
- memset(&today_end_t, 0, sizeof today_end_t);
- today_end_t.year = year;
- today_end_t.month = month;
- today_end_t.day = day;
- today_end_t.hour = 23;
- today_end_t.minute = 59;
+ memset(&starting_tm, 0, sizeof(struct tm));
+ starting_tm.tm_year = year - 1900;
+ starting_tm.tm_mon = month - 1;
+ starting_tm.tm_mday = day;
+ starting_tm.tm_hour = 0;
+ starting_tm.tm_min = 0;
+ today_start_t = icaltime_from_timet_with_zone(mktime(&starting_tm), 0, icaltimezone_get_utc_timezone());
+ today_start_t.is_utc = 1;
+
+ memset(&ending_tm, 0, sizeof(struct tm));
+ ending_tm.tm_year = year - 1900;
+ ending_tm.tm_mon = month - 1;
+ ending_tm.tm_mday = day;
+ ending_tm.tm_hour = 23;
+ ending_tm.tm_min = 59;
+ today_end_t = icaltime_from_timet_with_zone(mktime(&ending_tm), 0, icaltimezone_get_utc_timezone());
+ today_end_t.is_utc = 1;
/* Now loop through our list of events to see which ones occur today.
*/
icalproperty *q = NULL;
time_t event_start;
time_t event_end;
+ time_t event_tt;
+ time_t event_tte;
struct tm event_te;
struct tm event_tm;
int show_event = 0;
struct icaltimetype end_t;
struct icaltimetype today_start_t;
struct icaltimetype today_end_t;
+ struct tm starting_tm;
+ struct tm ending_tm;
if (WCC->num_cal == 0) {
/* Create an imaginary event which spans the 24 hours of today. Any events which
* overlap with this one take place at least partially in this day.
*/
- memset(&today_start_t, 0, sizeof today_start_t);
- today_start_t.year = year;
- today_start_t.month = month;
- today_start_t.day = day;
- today_start_t.hour = 0;
- today_start_t.minute = 0;
- memset(&today_end_t, 0, sizeof today_end_t);
- today_end_t.year = year;
- today_end_t.month = month;
- today_end_t.day = day;
- today_end_t.hour = 23;
- today_end_t.minute = 59;
-
+ memset(&starting_tm, 0, sizeof(struct tm));
+ starting_tm.tm_year = year - 1900;
+ starting_tm.tm_mon = month - 1;
+ starting_tm.tm_mday = day;
+ starting_tm.tm_hour = hour;
+ starting_tm.tm_min = 0;
+ today_start_t = icaltime_from_timet_with_zone(mktime(&starting_tm), 0, icaltimezone_get_utc_timezone());
+ today_start_t.is_utc = 1;
+
+ memset(&ending_tm, 0, sizeof(struct tm));
+ ending_tm.tm_year = year - 1900;
+ ending_tm.tm_mon = month - 1;
+ ending_tm.tm_mday = day;
+ ending_tm.tm_hour = hour;
+ ending_tm.tm_min = 59;
+ today_end_t = icaltime_from_timet_with_zone(mktime(&ending_tm), 0, icaltimezone_get_utc_timezone());
+/* today_end_t.is_utc = 1;*/
/* Now loop through our list of events to see which ones occur today.
*/
q = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
if (q != NULL) {
t = icalproperty_get_dtstart(q);
+ event_tt = icaltime_as_timet(t);
}
else {
memset(&t, 0, sizeof t);
if (all_day_event)
{
- show_event = ((t.year == year) && (t.month == month) && (t.day == day));
+ show_event = ((t.year == year) && (t.month == month) && (t.day == day) && (hour == -1));
}
else
{
show_event = ical_ctdl_is_overlap(t, end_t, today_start_t, today_end_t);
+ localtime_r(&event_tt, &event_te);
}
/* If we determined that this event occurs today, then display it.
}
else
{
+ event_tte = icaltime_as_timet(end_t);
+ localtime_r(&event_tte, &event_tm);
+ if (hour == event_te.tm_hour) {
wprintf("<dd class=\"event\" "
"style=\"position: absolute; "
"top:%dpx; left:100px; "
"height:%dpx; \" >",
- (100 + (event_tm.tm_min / 2) + (event_te.tm_hour - hour) + (hour * 30) - (dstart * 30)),
- (((event_te.tm_min - event_tm.tm_min) / 2) +(event_te.tm_hour - hour) * 30)
- );
- wprintf("<a href=\"display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d&hour=%d\">",
- Cal->cal_msgnum, year, month, day, hour);
+ ((dstart * 11) + (event_te.tm_hour - dstart) * (event_te.tm_hour < dstart? 11 : 31)),
+ ((event_tm.tm_hour - event_te.tm_hour) * 30)
+ );
+ wprintf("<a href=\"display_edit_event?msgnum=%ld&calview=day&year=%d&month=%d&day=%d&hour=%d&case=%d\">",
+ Cal->cal_msgnum, year, month, day, t.hour, hour);
escputs((char *) icalproperty_get_comment(p));
wprintf("</a></dd>\n");
+ }
+
}
}
}