Logo Search packages:      
Sourcecode: libical version File versions

int icaltime_days_in_month ( const int  month,
const int  year 
)

Return the number of days in the given month

Definition at line 595 of file icaltime.c.

{

    int days = _days_in_month[month];

/* The old code aborting if it was passed a parameter like BYMONTH=0
 * Unfortunately it's not practical right now to pass an error all
 * the way up the stack, so instead of aborting we're going to apply
 * the GIGO principle and simply return '30 days' if we get an
 * invalid month.  Modern applications cannot tolerate crashing.
 *  assert(month > 0);
 *  assert(month <= 12);
 */
    if ((month < 1) || (month > 12)) {
      return 30;
    }

    if( month == 2){
      days += icaltime_is_leap_year(year);
    }

    return days;
}


Generated by  Doxygen 1.6.0   Back to index