/* gcc test.c -o test `pkg-config --cflags --libs libical` && ./test */

#include <stdio.h>
#include <libical/ical.h>

int main (void)
{
	const char *str =
		"BEGIN:VEVENT\r\n"
		"UID:-OUR-CALENDAR-COM-CAL-__PUBLIC__-0000000021\r\n"
		"SUMMARY:Test VALUE X in DTSTART\r\n"
		"DTSTART;VALUE=X:20070122T000000Z\r\n"
		"DTEND;VALUE=DATE:20070123\r\n"
		"DTSTAMP:20080605T123147Z\r\n"
		"LAST-MODIFIED:20070110T122050Z\r\n"
		"RRULE:FREQ=DAILY;UNTIL=20070126T000000Z;INTERVAL=1\r\n"
		"END:VEVENT\r\n";
	icalcomponent *icomp;
	const char *tstr;
	struct icaltimetype itt;

	icomp = icalcomponent_new_from_string (str);
	if (!icomp) {
		fprintf (stderr, "Cannot parse str\n");
		return 1;
	}

	itt = icalcomponent_get_dtstart (icomp);
	tstr = icaltime_as_ical_string (itt);

	printf ("got '%s' expected '20070122T000000Z'\n", tstr);

	icalcomponent_free (icomp);

	return 0;
}
