From 7031ff29d1d0032293741e8ff48325702d1950e0 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 26 Jan 2007 05:30:28 +0000 Subject: [PATCH] * icaltime_from_webform() - removed an unnecessary conversion to and from time_t. A problem with libical was causing timestamps to get converted from local time zone to GMT twice. --- webcit/calendar_tools.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/webcit/calendar_tools.c b/webcit/calendar_tools.c index d62cb8296..304530f78 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -153,24 +153,22 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) { */ void icaltime_from_webform(struct icaltimetype *t, char *prefix) { char vname[32]; - time_t tt; - struct tm tm; struct icaltimetype t2; + char timestr[32]; + int month, mday, year, hour, minute; - tt = time(NULL); - localtime_r(&tt, &tm); + sprintf(vname, "%s_month", prefix); month = atoi(bstr(vname)); + sprintf(vname, "%s_day", prefix); mday = atoi(bstr(vname)); + sprintf(vname, "%s_year", prefix); year = atoi(bstr(vname)); + sprintf(vname, "%s_hour", prefix); hour = atoi(bstr(vname)); + sprintf(vname, "%s_minute", prefix); minute = atoi(bstr(vname)); - sprintf(vname, "%s_month", prefix); tm.tm_mon = atoi(bstr(vname)) - 1; - sprintf(vname, "%s_day", prefix); tm.tm_mday = atoi(bstr(vname)); - sprintf(vname, "%s_year", prefix); tm.tm_year = atoi(bstr(vname)) - 1900; - sprintf(vname, "%s_hour", prefix); tm.tm_hour = atoi(bstr(vname)); - sprintf(vname, "%s_minute", prefix); tm.tm_min = atoi(bstr(vname)); - - tt = mktime(&tm); - t2 = icaltime_from_timet(tt, 0); + sprintf(timestr, "%04d%02d%02dT%02d%02d00", year, month, mday, hour, minute); + t2 = icaltime_from_string(timestr); memcpy(t, &t2, sizeof(struct icaltimetype)); } + /** *\brief Get time from form * get the time back from the user and convert it into internal structs. -- 2.30.2