From ace76e6488a291023c89359e1ca35d2f006af07a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 15 Dec 2002 05:50:59 +0000 Subject: [PATCH] * Form editing of date/time fields now assumes that the icaltimetype being manipulated is in UTC. It converts to/from local time for editing. --- webcit/ChangeLog | 5 ++++ webcit/calendar_tools.c | 63 +++++++++++++++++++++++++++++------------ 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 76fb79219..dfc59c5fe 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 400.63 2002/12/15 05:50:59 ajc +* Form editing of date/time fields now assumes that the icaltimetype being + manipulated is in UTC. It converts to/from local time for editing. + Revision 400.62 2002/12/10 23:25:47 ajc * Display attendees in message view of calendar objects @@ -1164,3 +1168,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 10d898baf..7ece52fda 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -38,27 +38,51 @@ char *days[] = { #ifdef HAVE_ICAL_H +/* + * The display_icaltimetype_as_webform() and icaltime_from_webform() functions + * handle the display and editing of date/time properties in web pages. The + * first one converts an icaltimetype into valid HTML markup -- a series of form + * fields for editing the date and time. When the user submits the form, the + * results can be fed back into the second function, which turns it back into + * an icaltimetype. The "prefix" string required by both functions is prepended + * to all field names. This allows a form to contain more than one date/time + * property (for example, a start and end time) by ensuring the field names are + * unique within the form. + * + * NOTE: These functions assume that the icaltimetype being edited is in UTC, and + * will convert to/from local time for editing. "local" in this case is assumed + * to be the time zone in which the WebCit server is running. A future improvement + * might be to allow the user to specify his/her timezone. + */ + void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) { int i; + time_t now; - struct tm *tm; + struct tm *tm_now; int this_year; + + time_t tt; + struct tm *tm; + const int span = 10; now = time(NULL); - tm = localtime(&now); - this_year = tm->tm_year + 1900; + tm_now = localtime(&now); + this_year = tm_now->tm_year + 1900; if (t == NULL) return; + tt = icaltime_as_timet(*t); + tm = localtime(&tt); wprintf("Month: "); wprintf("\n"); @@ -67,7 +91,7 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) { wprintf("\n", prefix); for (i=0; i<=23; ++i) { wprintf("\n", - ((t->hour == i) ? "SELECTED" : ""), + ((tm->tm_hour == i) ? "SELECTED" : ""), i, i ); } @@ -105,7 +129,7 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) { wprintf("