diff options
author | Oz Linden <oz@lindenlab.com> | 2011-07-19 15:45:15 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2011-07-19 15:45:15 -0400 |
commit | 20e08f6aa7e260c07bbe367325dea9fb18b7bd4c (patch) | |
tree | d26961655587a0a0a666200b009b4d54dcf31af2 /indra | |
parent | 41890cfee81b1883f8f1c80cc07d4fddbffa6e75 (diff) | |
parent | cf8c7701dfd758a9f19e076baad0a9b8d37bbe5f (diff) |
merge changes for storm-1221
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/lldateutil.cpp | 27 | ||||
-rw-r--r-- | indra/newview/lldateutil.h | 14 | ||||
-rw-r--r-- | indra/newview/llpanelgrouplandmoney.cpp | 39 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/strings.xml | 2 |
4 files changed, 78 insertions, 4 deletions
diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp index 18ae6107e7..c7fc45f61e 100644 --- a/indra/newview/lldateutil.cpp +++ b/indra/newview/lldateutil.cpp @@ -27,10 +27,16 @@ #include "lldateutil.h" +#include <boost/date_time/gregorian/gregorian.hpp> +#include <boost/date_time/posix_time/ptime.hpp> + // Linden libraries #include "lltrans.h" #include "llui.h" +using namespace boost::gregorian; +using namespace boost::posix_time; + static S32 DAYS_PER_MONTH_NOLEAP[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static S32 DAYS_PER_MONTH_LEAP[] = @@ -186,3 +192,24 @@ std::string LLDateUtil::ageFromDate(const std::string& date_string) //{ // return ageFromDateISO(date_string, LLDate::now()); //} + +S32 LLDateUtil::secondsSinceEpochFromString(const std::string& format, const std::string& str) +{ + date_input_facet *facet = new date_input_facet(format); + + std::stringstream ss; + ss << str; + ss.imbue(std::locale(ss.getloc(), facet)); + + date d; + ss >> d; + + ptime time_t_date(d); + ptime time_t_epoch(date(1970,1,1)); + + // We assume that the date defined by str is in UTC, so the difference + // is calculated with no time zone corrections. + time_duration diff = time_t_date - time_t_epoch; + + return diff.total_seconds(); +} diff --git a/indra/newview/lldateutil.h b/indra/newview/lldateutil.h index 2843a357c9..f027d360f7 100644 --- a/indra/newview/lldateutil.h +++ b/indra/newview/lldateutil.h @@ -69,6 +69,20 @@ namespace LLDateUtil //std::string ageFromDateISO(const std::string& date_string); //std::string ageFromDate(S32 born_year, S32 born_month, S32 born_day, const LLDate& now); + + /** + * Convert a string of a specified date format into seconds since the Epoch. + * + * Many of the format flags are those used by strftime(...), but not all. + * For the full list of supported time format specifiers + * see http://www.boost.org/doc/libs/1_47_0/doc/html/date_time/date_time_io.html#date_time.format_flags + * + * @param format Format characters string. Example: "%A %b %d, %Y" + * @param str Date string containing the time in specified format. + * + * @return Number of seconds since 01/01/1970 UTC. + */ + S32 secondsSinceEpochFromString(const std::string& format, const std::string& str); } #endif diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp index 8d8d9bc1c4..eddd6e554d 100644 --- a/indra/newview/llpanelgrouplandmoney.cpp +++ b/indra/newview/llpanelgrouplandmoney.cpp @@ -35,6 +35,7 @@ #include "llqueryflags.h" #include "llagent.h" +#include "lldateutil.h" #include "lliconctrl.h" #include "llfloaterreg.h" #include "lllineeditor.h" @@ -1056,6 +1057,14 @@ void LLGroupMoneyDetailsTabEventHandler::processReply(LLMessageSystem* msg, msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval ); msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, start_date); + std::string time_str = LLTrans::getString("GroupMoneyDate"); + LLSD substitution; + + // We don't do time zone corrections of the calculated number of seconds + // because we don't have a full time stamp, only a date. + substitution["datetime"] = LLDateUtil::secondsSinceEpochFromString("%A %b %d, %Y", start_date); + LLStringUtil::format (time_str, substitution); + if ( interval_days != mImplementationp->mIntervalLength || current_interval != mImplementationp->mCurrentInterval ) { @@ -1064,7 +1073,7 @@ void LLGroupMoneyDetailsTabEventHandler::processReply(LLMessageSystem* msg, return; } - std::string text = start_date; + std::string text = time_str; text.append("\n\n"); S32 total_amount = 0; @@ -1203,7 +1212,15 @@ void LLGroupMoneySalesTabEventHandler::processReply(LLMessageSystem* msg, // Start with the date. if (text == mImplementationp->mLoadingText) { - text = start_date + "\n\n"; + std::string time_str = LLTrans::getString("GroupMoneyDate"); + LLSD substitution; + + // We don't do time zone corrections of the calculated number of seconds + // because we don't have a full time stamp, only a date. + substitution["datetime"] = LLDateUtil::secondsSinceEpochFromString("%A %b %d, %Y", start_date); + LLStringUtil::format (time_str, substitution); + + text = time_str + "\n\n"; } S32 transactions = msg->getNumberOfBlocksFast(_PREHASH_HistoryData); @@ -1408,12 +1425,26 @@ void LLGroupMoneyPlanningTabEventHandler::processReply(LLMessageSystem* msg, } text.append(LLTrans::getString("SummaryForTheWeek")); - text.append(start_date); + + std::string date_format_str = LLTrans::getString("GroupPlanningDate"); + std::string time_str = date_format_str; + LLSD substitution; + // We don't do time zone corrections of the calculated number of seconds + // because we don't have a full time stamp, only a date. + substitution["datetime"] = LLDateUtil::secondsSinceEpochFromString("%m/%d/%Y", start_date); + LLStringUtil::format (time_str, substitution); + + text.append(time_str); if (current_interval == 0) { text.append(LLTrans::getString("NextStipendDay")); - text.append(next_stipend_date); + + time_str = date_format_str; + substitution["datetime"] = LLDateUtil::secondsSinceEpochFromString("%m/%d/%Y", next_stipend_date); + LLStringUtil::format (time_str, substitution); + + text.append(time_str); text.append("\n\n"); text.append(llformat("%-24sL$%6d\n", LLTrans::getString("GroupMoneyBalance").c_str(), balance )); text.append(1, '\n'); diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index c1c1151eb9..ee6317f367 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -2238,6 +2238,7 @@ Returns a string with the requested data about the region <string name="Unknown">(Unknown)</string> <string name="SummaryForTheWeek" value="Summary for this week, beginning on " /> <string name="NextStipendDay" value="The next stipend day is " /> + <string name="GroupPlanningDate">[mthnum,datetime,utc]/[day,datetime,utc]/[year,datetime,utc]</string> <string name="GroupIndividualShare" value=" Group Individual Share" /> <string name="GroupColumn" value=" Group" /> <string name="Balance">Balance</string> @@ -2394,6 +2395,7 @@ Returns a string with the requested data about the region <string name="GroupMoneyBalance">Balance</string> <string name="GroupMoneyCredits">Credits</string> <string name="GroupMoneyDebits">Debits</string> + <string name="GroupMoneyDate">[weekday,datetime,utc] [mth,datetime,utc] [day,datetime,utc], [year,datetime,utc]</string> <!-- viewer object --> <string name="ViewerObjectContents">Contents</string> |