Use boost::date_time for displaying avatar age.

llpanelavatar change may be better viewed without space changes.
This commit is contained in:
Lirusaito
2012-12-20 23:34:05 -05:00
parent 3d25f8ee79
commit 237455f4b7
2 changed files with 13 additions and 26 deletions

View File

@@ -52,6 +52,7 @@
#include <string.h> #include <string.h>
#include <map> #include <map>
#include <boost/date_time.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
@@ -177,17 +178,10 @@ void LLAvatarListEntry::processProperties(void* data, EAvatarProcessorType type)
const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>(data); const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>(data);
if (pAvatarData && (pAvatarData->avatar_id != LLUUID::null)) if (pAvatarData && (pAvatarData->avatar_id != LLUUID::null))
{ {
//Chalice - Show avatar age in days. using namespace boost::gregorian;
int year, month, day; int year, month, day;
sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d",&month,&day,&year); sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d",&month,&day,&year);
time_t now = time(NULL); mAge = (day_clock::local_day() - date(year, month, day)).days();
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);
// If one wanted more information that gets displayed on profiles to be displayed, here would be the place to do it. // If one wanted more information that gets displayed on profiles to be displayed, here would be the place to do it.
} }
} }

View File

@@ -89,6 +89,7 @@
#include <iosfwd> #include <iosfwd>
#include <boost/date_time.hpp>
@@ -269,23 +270,15 @@ void LLPanelAvatarSecondLife::processProperties(void* data, EAvatarProcessorType
getChild<LLTextureCtrl>("img")->setImageAssetID(pAvatarData->image_id); getChild<LLTextureCtrl>("img")->setImageAssetID(pAvatarData->image_id);
//Chalice - Show avatar age in days. // Show avatar age in days.
int year, month, day; {
sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d",&month,&day,&year); using namespace boost::gregorian;
time_t now = time(NULL); int year, month, day;
struct tm * timeinfo; sscanf(pAvatarData->born_on.c_str(),"%d/%d/%d",&month,&day,&year);
timeinfo=localtime(&now); std::ostringstream born_on;
timeinfo->tm_mon = --month; born_on << pAvatarData->born_on << " (" << day_clock::local_day() - date(year, month, day) << ")";
timeinfo->tm_year = year - 1900; childSetValue("born", born_on.str());
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);
bool allow_publish = (pAvatarData->flags & AVATAR_ALLOW_PUBLISH); bool allow_publish = (pAvatarData->flags & AVATAR_ALLOW_PUBLISH);
childSetValue("allow_publish", allow_publish); childSetValue("allow_publish", allow_publish);