diff --git a/indra/newview/llfloateravatarlist.cpp b/indra/newview/llfloateravatarlist.cpp index 339b90f3c..17dcecf76 100644 --- a/indra/newview/llfloateravatarlist.cpp +++ b/indra/newview/llfloateravatarlist.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include @@ -177,17 +178,10 @@ void LLAvatarListEntry::processProperties(void* data, EAvatarProcessorType type) const LLAvatarData* pAvatarData = static_cast(data); if (pAvatarData && (pAvatarData->avatar_id != LLUUID::null)) { - //Chalice - Show avatar age in days. + using namespace boost::gregorian; int year, month, day; sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d",&month,&day,&year); - time_t now = time(NULL); - struct tm * timeinfo; - timeinfo=localtime(&now); - timeinfo->tm_mon = --month; - timeinfo->tm_year = year - 1900; - timeinfo->tm_mday = day; - time_t birth = mktime(timeinfo); - mAge = difftime(now,birth) / (60*60*24); + mAge = (day_clock::local_day() - date(year, month, day)).days(); // If one wanted more information that gets displayed on profiles to be displayed, here would be the place to do it. } } diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index cf1f3c23c..904a809c9 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -89,6 +89,7 @@ #include +#include @@ -269,23 +270,15 @@ void LLPanelAvatarSecondLife::processProperties(void* data, EAvatarProcessorType getChild("img")->setImageAssetID(pAvatarData->image_id); - //Chalice - Show avatar age in days. - int year, month, day; - sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d",&month,&day,&year); - time_t now = time(NULL); - struct tm * timeinfo; - timeinfo=localtime(&now); - timeinfo->tm_mon = --month; - timeinfo->tm_year = year - 1900; - timeinfo->tm_mday = day; - time_t birth = mktime(timeinfo); - std::stringstream NumberString; - NumberString << (difftime(now,birth) / (60*60*24)); - std::string born_on = pAvatarData->born_on; - born_on += " ("; - born_on += NumberString.str(); - born_on += ")"; - childSetValue("born", born_on); + // Show avatar age in days. + { + using namespace boost::gregorian; + int year, month, day; + sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d",&month,&day,&year); + std::ostringstream born_on; + born_on << pAvatarData->born_on << " (" << day_clock::local_day() - date(year, month, day) << ")"; + childSetValue("born", born_on.str()); + } bool allow_publish = (pAvatarData->flags & AVATAR_ALLOW_PUBLISH); childSetValue("allow_publish", allow_publish);