From fa9331a6e479ad13f0ee3e89774507acf11e4310 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 29 Sep 2002 20:15:43 +0000 Subject: [PATCH] * Completed the calendar day view --- webcit/ChangeLog | 4 ++ webcit/calendar_tools.c | 11 ++++++ webcit/calendar_view.c | 84 +++++++++++++++++++++++++++++++++-------- webcit/event.c | 24 +++++++----- 4 files changed, 98 insertions(+), 25 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 6c5e38b10..a0b996785 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 400.31 2002/09/29 20:15:43 ajc +* Completed the calendar day view + Revision 400.30 2002/09/28 04:01:30 ajc * started fleshing out the calendar day view @@ -1043,3 +1046,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/calendar_tools.c b/webcit/calendar_tools.c index 581d044d9..b7cf8fbe7 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -111,6 +111,10 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) { } wprintf("\n"); + wprintf(" All day event", + prefix, + ((t->is_date) ? "CHECKED" : "")); } @@ -128,6 +132,13 @@ struct icaltimetype icaltime_from_webform(char *prefix) { sprintf(vname, "%s_hour", prefix); t.hour = atoi(bstr(vname)); sprintf(vname, "%s_minute", prefix); t.minute = atoi(bstr(vname)); + sprintf(vname, "%s_alldayevent", prefix); + if (!strcasecmp(bstr(vname), "yes")) { + t.hour = 0; + t.minute = 0; + t.is_date = 1; + } + t = icaltime_normalize(t); return(t); } diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index ed5fd34e8..d43e49103 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -205,21 +205,57 @@ void calendar_week_view(int year, int month, int day) { } -void calendar_day_view(int year, int month, int day) { - struct tm starting_tm; - time_t thetime; +/* + * Display events for a particular hour of a particular day. + * (Specify hour < 0 to show "all day" events) + */ +void calendar_day_view_display_events(int year, int month, + int day, int hour) { int i; + icalproperty *p; + struct icaltimetype t; - /* Determine what day we're viewing. - */ - memset(&starting_tm, 0, sizeof(struct tm)); - starting_tm.tm_year = year - 1900; - starting_tm.tm_mon = month - 1; - starting_tm.tm_mday = day; - thetime = mktime(&starting_tm); + if (WC->num_cal == 0) { + wprintf("


\n"); + return; + } + + for (i=0; i<(WC->num_cal); ++i) { + p = icalcomponent_get_first_property(WC->disp_cal[i], + ICAL_DTSTART_PROPERTY); + if (p != NULL) { + t = icalproperty_get_dtstart(p); + if ((t.year == year) + && (t.month == month) + && (t.day == day) + && ( (t.hour == hour) || ((hour<0)&&(t.is_date)) ) + ) { + + p = icalcomponent_get_first_property( + WC->disp_cal[i], + ICAL_SUMMARY_PROPERTY); + if (p != NULL) { + wprintf("" + "", + WC->cal_msgnum[i], + year, month, day + ); + escputs((char *) + icalproperty_get_comment(p)); + wprintf("\n"); + } + + } + + + } + } +} -/**********************************************************************/ + +void calendar_day_view(int year, int month, int day) { + int hour; /* Outer table (to get the background color) */ wprintf("\n"); - /* Now do 7 hours */ - for (i = 0; i < 7; ++i) { - wprintf("\n"); - /* put the data here, stupid ... FIXME add hour */ - calendar_month_view_display_events(thetime); + /* Now the middle of the day... */ + for (hour = 8; hour <= 17; ++hour) { /* could do HEIGHT=xx */ + wprintf("\n"); } + /* Display events after 5:00... */ + wprintf("\n"); + + wprintf("
"); + /* Display events before 8:00 (hour=-1 is all-day events) */ + wprintf("
"); + for (hour = (-1); hour <= 7; ++hour) { + calendar_day_view_display_events(year, month, day, hour); + } + wprintf("
"); + wprintf("%d:00 ", hour); + + /* put the data here, stupid */ + calendar_day_view_display_events(year, month, day, hour); wprintf("
"); + for (hour = 18; hour <= 23; ++hour) { + calendar_day_view_display_events(year, month, day, hour); + } + wprintf("
" /* end of innermost table */ "" /* end of inner table */ "" /* end of outer table */ diff --git a/webcit/event.c b/webcit/event.c index d9ae239f8..df2b63a21 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -70,16 +70,20 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) wprintf("\n", bstr("day")); - wprintf("Summary: " + + /* Put it in a borderless table so it lines up nicely */ + wprintf("\n"); + + wprintf("\n"); - wprintf("Start date/time: "); + wprintf("\n"); - wprintf("End date/time: "); + wprintf("\n"); - wprintf("

\n"); + wprintf("
Summary\n" "
\n"); + wprintf("\">
Start\n"); p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY); if (p != NULL) { t = icalproperty_get_dtstart(p); @@ -88,9 +92,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) t = icaltime_from_timet(now, 0); } display_icaltimetype_as_webform(&t, "dtstart"); - wprintf("
\n"); + wprintf("
End\n"); p = icalcomponent_get_first_property(vevent, ICAL_DTEND_PROPERTY); if (p != NULL) { t = icalproperty_get_dtend(p); @@ -99,18 +103,20 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) t = icaltime_from_timet(now, 0); } display_icaltimetype_as_webform(&t, "dtend"); - wprintf("
\n"); + wprintf("
\n"); - wprintf("" + wprintf("
" + "" "  " "\n" "  " -- 2.30.2