summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/coreutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util/coreutil.c')
-rw-r--r--src/lib/util/coreutil.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lib/util/coreutil.c b/src/lib/util/coreutil.c
index eb7d2a92d89..87df296dd56 100644
--- a/src/lib/util/coreutil.c
+++ b/src/lib/util/coreutil.c
@@ -82,12 +82,11 @@ int gregorian_is_leap_year(int year)
int gregorian_days_in_month(int month, int year)
{
- if (month == 2)
- return gregorian_is_leap_year(year) ? 29 : 28;
- else if (month == 4 || month == 6 || month == 9 || month == 11)
- return 30;
- else
- return 31;
+ assert(month >= 1 && month <= 12)
+
+ int days[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
+ days[1] += gregorian_is_leap_year(year) ? 1 : 0;
+ return days[month-1];
}
@@ -121,4 +120,4 @@ void rand_memory(void *memory, size_t length)
UINT32 core_crc32(UINT32 crc, const UINT8 *buf, UINT32 len)
{
return crc32(crc, buf, len);
-} \ No newline at end of file
+}