アットウィキロゴ

指定年月の月末の日付を返却します。

#define TRUE   0
#define FALSE -1

/* is leap or not */
int IsLeapYear(int year)
{
if (((year % 4 == 0) && (year % 100 != 0)) || year % 400 == 0) {
return TRUE;
} else {
return FALSE;
}
}

/* get the last day of month */
int GetLastDay(int year, int month)
{
int leap;
int lmdays[] = {31,29,31,30,31,30,31,31,30,31,30,31};
int mdays[] = {31,28,31,30,31,30,31,31,30,31,30,31};

leap = = IsLeapYear(year);
// leap year
if (leap == TRUE) {
return lmdays[month - 1];
// no_leap year
} else {
return mdays[month - 1];
}
}

 

最終更新:2008年08月24日 18:54