home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
463.lha
/
Date_routines
/
valid_date.c
< prev
next >
Wrap
Text File
|
1991-01-04
|
742b
|
32 lines
/*****
valid_date()
This function determines whether a date is valid.
Argument list: int month the month
int day the day
int year the year
Return value: int 1 if valid, 0 if not
*****/
int valid_date(int day, int month, int year)
{
static int days[] = {0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
if (month > 12 || month < 1 || day > 31 || day < 1)
return 0;
if (day > days[month]) {
if (month == 2 && day == 29) { /* Special check for leap year */
if (leapyear(year)) {
return 1;
}
}
return 0;
}
return 1;
}