* icaltime_from_webform() - removed an unnecessary conversion
authorArt Cancro <ajc@citadel.org>
Fri, 26 Jan 2007 05:30:28 +0000 (05:30 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 26 Jan 2007 05:30:28 +0000 (05:30 +0000)
  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

index d62cb8296907e4f39606297176ea92b3350e4675..304530f784d080ab8b913c26acfa392d86f0a84a 100644 (file)
@@ -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.