X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fcalendar_tools.c;h=b595d74a50fbdc8d6e961937fd8b22cc0feb138f;hb=95c68e72bacfa2e88df8bcc1f5e726158b764ae3;hp=334e6a7d313186b3e033c9c7c004d2a83271d809;hpb=05c44eb3f726caa4b2bab912ebd92068d7bb6644;p=citadel.git diff --git a/webcit/calendar_tools.c b/webcit/calendar_tools.c index 334e6a7d3..b595d74a5 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -123,6 +123,8 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int d void icaltime_from_webform(struct icaltimetype *t, char *prefix) { char vname[32]; + if (!t) return; + /* Stuff with zero values */ memset(t, 0, sizeof(struct icaltimetype)); @@ -139,6 +141,7 @@ void icaltime_from_webform(struct icaltimetype *t, char *prefix) { /* time zone is set to the default zone for this server */ t->is_utc = 0; + t->is_date = 0; t->zone = get_default_icaltimezone(); } @@ -147,18 +150,17 @@ void icaltime_from_webform(struct icaltimetype *t, char *prefix) { * Get date (no time) from a web form and convert it into an icaltimetype struct. */ void icaltime_from_webform_dateonly(struct icaltimetype *t, char *prefix) { - struct tm tm; - time_t tm_t; - struct icaltimetype t2; - - /* Stuff tm with zero values */ - memset(&tm, 0, sizeof(struct tm)); - - /* Convert from string to icaltimetype */ - strptime((char *)BSTR(prefix), "%Y-%m-%d", &tm); - tm_t = mktime(&tm); - t2 = icaltime_from_timet(tm_t, 1); - memcpy(t, &t2, sizeof(struct icaltimetype)); + if (!t) return; + + /* Stuff with zero values */ + memset(t, 0, sizeof(struct icaltimetype)); + + /* Get the year/month/date all in one shot -- it will be in ISO YYYY-MM-DD format */ + sscanf((char*)BSTR(prefix), "%04d-%02d-%02d", &t->year, &t->month, &t->day); + + /* time zone is set to the default zone for this server */ + t->is_utc = 1; + t->is_date = 1; }