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

Remove unused date code after review with Leyla. Will unbreak Mac build.

parent fc04d5bb
No related branches found
No related tags found
No related merge requests found
...@@ -37,35 +37,6 @@ ...@@ -37,35 +37,6 @@
#include "lltrans.h" #include "lltrans.h"
#include "llui.h" #include "llui.h"
static S32 age_days_from_date(const std::string& date_string,
const LLDate& now)
{
// Convert string date to malleable representation
S32 month, day, year;
S32 matched = sscanf(date_string.c_str(), "%d/%d/%d", &month, &day, &year);
if (matched != 3) return S32_MIN;
// Create ISO-8601 date string
std::string iso8601_date_string =
llformat("%04d-%02d-%02dT00:00:00Z", year, month, day);
LLDate date(iso8601_date_string);
// Correct for the fact that account creation dates are in Pacific time,
// == UTC - 8
F64 date_secs_since_epoch = date.secondsSinceEpoch();
date_secs_since_epoch += 8.0 * 60.0 * 60.0;
// Convert seconds from epoch to seconds from now
F64 now_secs_since_epoch = now.secondsSinceEpoch();
F64 age_secs = now_secs_since_epoch - date_secs_since_epoch;
// We don't care about sub-day times
const F64 SEC_PER_DAY = 24.0 * 60.0 * 60.0;
S32 age_days = lltrunc(age_secs / SEC_PER_DAY);
return age_days;
}
static S32 DAYS_PER_MONTH_NOLEAP[] = static S32 DAYS_PER_MONTH_NOLEAP[] =
{ 31, 28, 21, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; { 31, 28, 21, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static S32 DAYS_PER_MONTH_LEAP[] = static S32 DAYS_PER_MONTH_LEAP[] =
...@@ -88,17 +59,6 @@ static S32 days_from_month(S32 year, S32 month) ...@@ -88,17 +59,6 @@ static S32 days_from_month(S32 year, S32 month)
std::string LLDateUtil::ageFromDate(const std::string& date_string, std::string LLDateUtil::ageFromDate(const std::string& date_string,
const LLDate& now) const LLDate& now)
{ {
#define BAD_DATE_MATH 0
#if BAD_DATE_MATH
S32 age_days = age_days_from_date(date_string, now);
if (age_days == S32_MIN) return "???";
S32 age_years = age_days / 365;
age_days = age_days % 365;
// *NOTE: This is wrong. Not all months have 30 days, but we don't have a library
// for relative date arithmetic. :-( JC
S32 age_months = age_days / 30;
age_days = age_days % 30;
#else
S32 born_month, born_day, born_year; S32 born_month, born_day, born_year;
S32 matched = sscanf(date_string.c_str(), "%d/%d/%d", &born_month, &born_day, &born_year); S32 matched = sscanf(date_string.c_str(), "%d/%d/%d", &born_month, &born_day, &born_year);
if (matched != 3) return "???"; if (matched != 3) return "???";
...@@ -135,7 +95,6 @@ std::string LLDateUtil::ageFromDate(const std::string& date_string, ...@@ -135,7 +95,6 @@ std::string LLDateUtil::ageFromDate(const std::string& date_string,
age_months += 12; age_months += 12;
} }
S32 age_years = (now_year - born_year); S32 age_years = (now_year - born_year);
#endif
// Noun pluralization depends on language // Noun pluralization depends on language
std::string lang = LLUI::getLanguage(); std::string lang = LLUI::getLanguage();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment