Native/C
Number of days in the given month (월에 마지막 일 알기)
aucd29
2013. 10. 2. 18:53
Link : http://www.php.net
[code]
static int ml_table_common[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static int ml_table_leap[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
#define timelib_is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m)
{
return timelib_is_leap(y) ? ml_table_leap[m] : ml_table_common[m];
}
[/code]
[code]
static int ml_table_common[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static int ml_table_leap[13] = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
#define timelib_is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m)
{
return timelib_is_leap(y) ? ml_table_leap[m] : ml_table_common[m];
}
[/code]