summaryrefslogtreecommitdiff
path: root/indra/newview/llavatarlistitem.cpp
diff options
context:
space:
mode:
authorVadim Savchuk <vsavchuk@productengine.com>2009-11-24 22:59:00 +0200
committerVadim Savchuk <vsavchuk@productengine.com>2009-11-24 22:59:00 +0200
commita7d2130464fa5e73ba7faf8b697b98443e80257a (patch)
treed7b8cb2837e525fcb83e2fb31a6b4332a806f1bc /indra/newview/llavatarlistitem.cpp
parent11a9fe3e7c10fddee6bcf4294e852f6ae389e3d6 (diff)
Fixed major bug EXT-2701 (Recent People > last_interaction value is not internationalized).
Made the avatar last interaction time localizeable. This also fixes task EXT-1096 (Implement Recent time in Recent People list for Avatar items). --HG-- branch : product-engine
Diffstat (limited to 'indra/newview/llavatarlistitem.cpp')
-rw-r--r--indra/newview/llavatarlistitem.cpp52
1 files changed, 50 insertions, 2 deletions
diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp
index c670a65bcc..efc9538fa6 100644
--- a/indra/newview/llavatarlistitem.cpp
+++ b/indra/newview/llavatarlistitem.cpp
@@ -198,9 +198,9 @@ void LLAvatarListItem::showLastInteractionTime(bool show)
mAvatarName->setRect(name_rect);
}
-void LLAvatarListItem::setLastInteractionTime(const std::string& val)
+void LLAvatarListItem::setLastInteractionTime(U32 secs_since)
{
- mLastInteractionTime->setValue(val);
+ mLastInteractionTime->setValue(formatSeconds(secs_since));
}
void LLAvatarListItem::setShowInfoBtn(bool show)
@@ -326,3 +326,51 @@ void LLAvatarListItem::reshapeAvatarName()
mAvatarName->reshape(width, height);
}
+
+// Convert given number of seconds to a string like "23 minutes", "15 hours" or "3 years",
+// taking i18n into account. The format string to use is taken from the panel XML.
+std::string LLAvatarListItem::formatSeconds(U32 secs)
+{
+ static const U32 LL_ALI_MIN = 60;
+ static const U32 LL_ALI_HOUR = LL_ALI_MIN * 60;
+ static const U32 LL_ALI_DAY = LL_ALI_HOUR * 24;
+ static const U32 LL_ALI_WEEK = LL_ALI_DAY * 7;
+ static const U32 LL_ALI_MONTH = LL_ALI_DAY * 30;
+ static const U32 LL_ALI_YEAR = LL_ALI_DAY * 365;
+
+ std::string fmt;
+ U32 count = 0;
+
+ if (secs >= LL_ALI_YEAR)
+ {
+ fmt = "FormatYears"; count = secs / LL_ALI_YEAR;
+ }
+ else if (secs >= LL_ALI_MONTH)
+ {
+ fmt = "FormatMonths"; count = secs / LL_ALI_MONTH;
+ }
+ else if (secs >= LL_ALI_WEEK)
+ {
+ fmt = "FormatWeeks"; count = secs / LL_ALI_WEEK;
+ }
+ else if (secs >= LL_ALI_DAY)
+ {
+ fmt = "FormatDays"; count = secs / LL_ALI_DAY;
+ }
+ else if (secs >= LL_ALI_HOUR)
+ {
+ fmt = "FormatHours"; count = secs / LL_ALI_HOUR;
+ }
+ else if (secs >= LL_ALI_MIN)
+ {
+ fmt = "FormatMinutes"; count = secs / LL_ALI_MIN;
+ }
+ else
+ {
+ fmt = "FormatSeconds"; count = secs;
+ }
+
+ LLStringUtil::format_map_t args;
+ args["[COUNT]"] = llformat("%u", count);
+ return getString(fmt, args);
+}