Skip to content
Snippets Groups Projects
Commit cffe23df authored by James Cook's avatar James Cook
Browse files

EXT-3921 [BSI] Age calculation fails on Mac and Linux

Was accessing wrong value out of days-per-month array, and
stepping off end of array for December.
Reviewed with Richard.
parent e1283e0b
Branches
Tags
No related merge requests found
...@@ -44,15 +44,18 @@ static S32 DAYS_PER_MONTH_LEAP[] = ...@@ -44,15 +44,18 @@ static S32 DAYS_PER_MONTH_LEAP[] =
static S32 days_from_month(S32 year, S32 month) static S32 days_from_month(S32 year, S32 month)
{ {
llassert_always(1 <= month);
llassert_always(month <= 12);
if (year % 4 == 0 if (year % 4 == 0
&& year % 100 != 0) && year % 100 != 0)
{ {
// leap year // leap year
return DAYS_PER_MONTH_LEAP[month]; return DAYS_PER_MONTH_LEAP[month - 1];
} }
else else
{ {
return DAYS_PER_MONTH_NOLEAP[month]; return DAYS_PER_MONTH_NOLEAP[month - 1];
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment