From cffe23df08bb0066c936efe667f60e90e0f89fd0 Mon Sep 17 00:00:00 2001
From: James Cook <james@lindenlab.com>
Date: Tue, 5 Jan 2010 15:46:40 -0800
Subject: [PATCH] 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.

---
 indra/newview/lldateutil.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp
index 10b7935caf0..abb2fdeb9a0 100644
--- a/indra/newview/lldateutil.cpp
+++ b/indra/newview/lldateutil.cpp
@@ -44,15 +44,18 @@ static S32 DAYS_PER_MONTH_LEAP[] =
 
 static S32 days_from_month(S32 year, S32 month)
 {
+	llassert_always(1 <= month);
+	llassert_always(month <= 12);
+
 	if (year % 4 == 0 
 		&& year % 100 != 0)
 	{
 		// leap year
-		return DAYS_PER_MONTH_LEAP[month];
+		return DAYS_PER_MONTH_LEAP[month - 1];
 	}
 	else
 	{
-		return DAYS_PER_MONTH_NOLEAP[month];
+		return DAYS_PER_MONTH_NOLEAP[month - 1];
 	}
 }
 
-- 
GitLab