There is a bug in libical's icaltime_compare_date_only routine. If the dates are stored in different time zones, the comparision becomes incorrect. For example, if I'm comparing 9 PM in Eastern Time to 1 AM UTC, they should be the same date -- but because of the different time zones, they appear as different days. The answer is to convert both dates into the same time zone. The addition of a 'tz' parameter allows the time zone to be selected, at the expense of requiring all calls to the function to have a parameter added. If passed in as NULL, then UTC zone is used. I apologize for presenting this in this rather stupid manner, but I can't/don't want to figure out freshmeat to create a bug report or patch. /** * like icaltime_compare, but only use the date parts. */ int icaltime_compare_date_only(const struct icaltimetype a_in, const struct icaltimetype b_in, const icaltimezone *tz) { int retval; struct icaltimetype a, b; /* We may need to select a time zone to compare, to avoid stupidity where 9 PM Saturday matches Sunday because we're in America, which is a couple hours off from UTC, and such similar stupidity. */ a = icaltime_convert_to_zone(a_in, tz == 0 ? icaltimezone_get_utc_timezone() : tz); b = icaltime_convert_to_zone(b_in, tz == 0 ? icaltimezone_get_utc_timezone() : tz);