From 305ec89a70bf88fce8f5edda15047182bc56682b Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 23 Feb 2010 16:33:43 -0800 Subject: Added ageFromDateISO() for YYYY-MM-DD dates --- indra/newview/lldateutil.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'indra/newview/lldateutil.cpp') diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp index abb2fdeb9a..150edb5bf8 100644 --- a/indra/newview/lldateutil.cpp +++ b/indra/newview/lldateutil.cpp @@ -59,12 +59,9 @@ static S32 days_from_month(S32 year, S32 month) } } -std::string LLDateUtil::ageFromDate(const std::string& date_string, - const LLDate& now) +static std::string age_from_date(S32 born_year, S32 born_month, S32 born_day, + const LLDate& now) { - S32 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 "???"; LLDate born_date; born_date.fromYMDHMS(born_year, born_month, born_day); F64 born_date_secs_since_epoch = born_date.secondsSinceEpoch(); @@ -155,7 +152,31 @@ std::string LLDateUtil::ageFromDate(const std::string& date_string, return LLTrans::getString("TodayOld"); } +std::string LLDateUtil::ageFromDate(const std::string& date_string, + const LLDate& now) +{ + S32 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 "???"; + return age_from_date(born_year, born_month, born_day, now); +} + std::string LLDateUtil::ageFromDate(const std::string& date_string) { return ageFromDate(date_string, LLDate::now()); } + +std::string LLDateUtil::ageFromDateISO(const std::string& date_string, + const LLDate& now) +{ + S32 born_month, born_day, born_year; + S32 matched = sscanf(date_string.c_str(), "%d-%d-%d", + &born_year, &born_month, &born_day); + if (matched != 3) return "???"; + return age_from_date(born_year, born_month, born_day, now); +} + +std::string LLDateUtil::ageFromDateISO(const std::string& date_string) +{ + return ageFromDateISO(date_string, LLDate::now()); +} -- cgit v1.2.3 From 6d1e44b0338dd2815f605a5ba6e6528932cf3ebc Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 20 Apr 2010 14:52:09 -0700 Subject: Avatar picker requests are routed via sim capability --- indra/newview/lldateutil.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/lldateutil.cpp') diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp index 150edb5bf8..1a13cd05fd 100644 --- a/indra/newview/lldateutil.cpp +++ b/indra/newview/lldateutil.cpp @@ -180,3 +180,8 @@ std::string LLDateUtil::ageFromDateISO(const std::string& date_string) { return ageFromDateISO(date_string, LLDate::now()); } + +std::string LLDateUtil::ageFromDate(S32 year, S32 month, S32 day) +{ + return age_from_date(year, month, day, LLDate::now()); +} -- cgit v1.2.3 From 257c3ed2a3747256500f704f6e06e7631af3c08e Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 20 Apr 2010 16:06:25 -0700 Subject: LLDateUtil::ageFromDate() now takes more sensible parameters This and last reviewed with Kelly --- indra/newview/lldateutil.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'indra/newview/lldateutil.cpp') diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp index 1a13cd05fd..32b8b9662a 100644 --- a/indra/newview/lldateutil.cpp +++ b/indra/newview/lldateutil.cpp @@ -59,8 +59,10 @@ static S32 days_from_month(S32 year, S32 month) } } -static std::string age_from_date(S32 born_year, S32 born_month, S32 born_day, - const LLDate& now) +std::string LLDateUtil::ageFromDate(S32 born_year, + S32 born_month, + S32 born_day, + const LLDate& now) { LLDate born_date; born_date.fromYMDHMS(born_year, born_month, born_day); @@ -158,7 +160,7 @@ std::string LLDateUtil::ageFromDate(const std::string& date_string, S32 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 "???"; - return age_from_date(born_year, born_month, born_day, now); + return ageFromDate(born_year, born_month, born_day, now); } std::string LLDateUtil::ageFromDate(const std::string& date_string) @@ -173,15 +175,10 @@ std::string LLDateUtil::ageFromDateISO(const std::string& date_string, S32 matched = sscanf(date_string.c_str(), "%d-%d-%d", &born_year, &born_month, &born_day); if (matched != 3) return "???"; - return age_from_date(born_year, born_month, born_day, now); + return ageFromDate(born_year, born_month, born_day, now); } std::string LLDateUtil::ageFromDateISO(const std::string& date_string) { return ageFromDateISO(date_string, LLDate::now()); } - -std::string LLDateUtil::ageFromDate(S32 year, S32 month, S32 day) -{ - return age_from_date(year, month, day, LLDate::now()); -} -- cgit v1.2.3 From 5aa8b5d37eb6824865d09af248aa9d9d518daeb9 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 11 May 2010 17:27:14 -0700 Subject: Clean up merge, dueling LLDateUtil refactoring --- indra/newview/lldateutil.cpp | 72 +++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 31 deletions(-) (limited to 'indra/newview/lldateutil.cpp') diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp index 32b8b9662a..ae955b6cad 100644 --- a/indra/newview/lldateutil.cpp +++ b/indra/newview/lldateutil.cpp @@ -59,18 +59,22 @@ static S32 days_from_month(S32 year, S32 month) } } -std::string LLDateUtil::ageFromDate(S32 born_year, - S32 born_month, - S32 born_day, - const LLDate& now) +bool LLDateUtil::dateFromPDTString(LLDate& date, const std::string& str) { - LLDate born_date; - born_date.fromYMDHMS(born_year, born_month, born_day); - F64 born_date_secs_since_epoch = born_date.secondsSinceEpoch(); - // Correct for the fact that account creation dates are in Pacific time, - // == UTC - 8 - born_date_secs_since_epoch += 8.0 * 60.0 * 60.0; - born_date.secondsSinceEpoch(born_date_secs_since_epoch); + S32 month, day, year; + S32 matched = sscanf(str.c_str(), "%d/%d/%d", &month, &day, &year); + if (matched != 3) return false; + date.fromYMDHMS(year, month, day); + F64 secs_since_epoch = date.secondsSinceEpoch(); + // Correct for the fact that specified date is in Pacific time, == UTC - 8 + secs_since_epoch += 8.0 * 60.0 * 60.0; + date.secondsSinceEpoch(secs_since_epoch); + return true; +} + +std::string LLDateUtil::ageFromDate(const LLDate& born_date, const LLDate& now) +{ + S32 born_month, born_day, born_year; // explode out to month/day/year again born_date.split(&born_year, &born_month, &born_day); @@ -154,13 +158,14 @@ std::string LLDateUtil::ageFromDate(S32 born_year, return LLTrans::getString("TodayOld"); } -std::string LLDateUtil::ageFromDate(const std::string& date_string, - const LLDate& now) +std::string LLDateUtil::ageFromDate(const std::string& date_string, const LLDate& now) { - S32 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 "???"; - return ageFromDate(born_year, born_month, born_day, now); + LLDate born_date; + + if (!dateFromPDTString(born_date, date_string)) + return "???"; + + return ageFromDate(born_date, now); } std::string LLDateUtil::ageFromDate(const std::string& date_string) @@ -168,17 +173,22 @@ std::string LLDateUtil::ageFromDate(const std::string& date_string) return ageFromDate(date_string, LLDate::now()); } -std::string LLDateUtil::ageFromDateISO(const std::string& date_string, - const LLDate& now) -{ - S32 born_month, born_day, born_year; - S32 matched = sscanf(date_string.c_str(), "%d-%d-%d", - &born_year, &born_month, &born_day); - if (matched != 3) return "???"; - return ageFromDate(born_year, born_month, born_day, now); -} - -std::string LLDateUtil::ageFromDateISO(const std::string& date_string) -{ - return ageFromDateISO(date_string, LLDate::now()); -} +//std::string LLDateUtil::ageFromDateISO(const std::string& date_string, +// const LLDate& now) +//{ +// S32 born_month, born_day, born_year; +// S32 matched = sscanf(date_string.c_str(), "%d-%d-%d", +// &born_year, &born_month, &born_day); +// if (matched != 3) return "???"; +// date.fromYMDHMS(year, month, day); +// F64 secs_since_epoch = date.secondsSinceEpoch(); +// // Correct for the fact that specified date is in Pacific time, == UTC - 8 +// secs_since_epoch += 8.0 * 60.0 * 60.0; +// date.secondsSinceEpoch(secs_since_epoch); +// return ageFromDate(born_year, born_month, born_day, now); +//} +// +//std::string LLDateUtil::ageFromDateISO(const std::string& date_string) +//{ +// return ageFromDateISO(date_string, LLDate::now()); +//} -- cgit v1.2.3