Logo Search packages:      
Sourcecode: libical version File versions

int icaltime_compare ( const struct icaltimetype  a_in,
const struct icaltimetype  b_in 
)

Return -1, 0, or 1 to indicate that a<b, a==b or a>b

Return -1, 0, or 1 to indicate that a<b, a==b, or a>b. This calls icaltime_compare function after converting them to the utc timezone.

Definition at line 824 of file icaltime.c.

References icaltimezone_get_utc_timezone().

{
    struct icaltimetype a, b;

    a = icaltime_convert_to_zone(a_in, icaltimezone_get_utc_timezone());
    b = icaltime_convert_to_zone(b_in, icaltimezone_get_utc_timezone());

    if (a.year > b.year)
      return 1;
    else if (a.year < b.year)
      return -1;

    else if (a.month > b.month)
      return 1;
    else if (a.month < b.month)
      return -1;

    else if (a.day > b.day)
      return 1;
    else if (a.day < b.day)
      return -1;

    /* if both are dates, we are done */
    if (a.is_date && b.is_date)
      return 0;

    /* else, if only one is a date (and we already know the date part is equal),
       then the other is greater */
    else if (b.is_date)
      return 1;
    else if (a.is_date)
      return -1;

    else if (a.hour > b.hour)
      return 1;
    else if (a.hour < b.hour)
      return -1;

    else if (a.minute > b.minute)
      return 1;
    else if (a.minute < b.minute)
      return -1;

    else if (a.second > b.second)
      return 1;
    else if (a.second < b.second)
      return -1;

    return 0;
}


Generated by  Doxygen 1.6.0   Back to index