diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ebcf3699f6..5cfccceb0d 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -353,6 +353,17 @@ Value 0 + FSTPHistoryTZ + + Comment + Select the timezone to be used with Teleport History. ('utc' = default, 'slt' = Second Life Time, 'local' = the local timezone of the client) + Persist + 1 + Type + String + Value + utc + ShowStreamMetadata Comment diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp index 394a84c015..94b602fe54 100644 --- a/indra/newview/llpanelteleporthistory.cpp +++ b/indra/newview/llpanelteleporthistory.cpp @@ -46,7 +46,9 @@ #include "lllandmarkactions.h" #include "llclipboard.h" #include "lltrans.h" - +// +#include +// #include "llviewercontrol.h" #include "fsfloaterplacedetails.h" @@ -254,6 +256,13 @@ std::string LLTeleportHistoryFlatItem::getTimestamp() LLSD args; args["datetime"] = date.secondsSinceEpoch(); timestamp = getString("DateFmt"); + // + // Check whether we have an override for the timezone + static const std::string xml_timezone = "utc"; // In case we decide to change the XML default ! + static LLCachedControl sFSTPHistoryTZ(gSavedSettings, "FSTPHistoryTZ"); + boost::replace_all(timestamp, xml_timezone, sFSTPHistoryTZ()); + LL_DEBUGS() << "Replacement DateFmt: " << timestamp << LL_ENDL; + // LLStringUtil::format(timestamp, args); // @@ -510,6 +519,10 @@ LLTeleportHistoryPanel::LLTeleportHistoryPanel() mIsStandAlone(false) // { + // [timezone support for teleport history] + mCommitCallbackRegistrar.add("TeleportHistory.TimeZone.Set", boost::bind(&LLTeleportHistoryPanel::onTimeZoneChecked, this, _2)); + mEnableCallbackRegistrar.add("TeleportHistory.TimeZone.Check", boost::bind(&LLTeleportHistoryPanel::isTimeZoneChecked, this, _2)); + // buildFromFile( "panel_teleport_history.xml"); } @@ -581,7 +594,6 @@ BOOL LLTeleportHistoryPanel::postBuild() registrar.add("TeleportHistory.CollapseAllFolders", boost::bind(&LLTeleportHistoryPanel::onCollapseAllFolders, this)); registrar.add("TeleportHistory.ClearTeleportHistory", boost::bind(&LLTeleportHistoryPanel::onClearTeleportHistory, this)); mEnableCallbackRegistrar.add("TeleportHistory.GearMenu.Enable", boost::bind(&LLTeleportHistoryPanel::isActionEnabled, this, _2)); - // mMenuGearButton = getChild("gear_btn"); // LLToggleableMenu* gear_menu = LLUICtrlFactory::getInstance()->createFromFile("menu_teleport_history_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());; @@ -723,14 +735,50 @@ void LLTeleportHistoryPanel::updateVerbs() void LLTeleportHistoryPanel::getNextTab(const LLDate& item_date, S32& tab_idx, LLDate& tab_date) { const U32 seconds_in_day = 24 * 60 * 60; - + // + static LLCachedControl sFSTPHistoryTZ(gSavedSettings, "FSTPHistoryTZ"); + // S32 tabs_cnt = mItemContainers.size(); S32 curr_year = 0, curr_month = 0, curr_day = 0; - tab_date = LLDate::now(); + tab_date = LLDate::now(); + // + // 1) Tab_date is now() which is UTC so we need to onvert that to timezoen by dedcuting the offset + // before we flatten to current day + // Given currrent date/time in UTC (tab_date) apply the offset for the users selected preference + // Must be done before the split and adjust to get midnight today + if (sFSTPHistoryTZ() == "local") // local + { + tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() - LLStringOps::getLocalTimeOffset()); + } + else if (sFSTPHistoryTZ() != "utc") // slt + { + // note that SLT is a +ve offset + tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() - LLStringOps::getPacificTimeOffset()); + } + // we now have the adjusted date time which maybe a different day to the UTC day + // tab_date.split(&curr_year, &curr_month, &curr_day); tab_date.fromYMDHMS(curr_year, curr_month, curr_day); // Set hour, min, and sec to 0 tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() + seconds_in_day); + // + // 2) Tab_date is cutrrently last second of the selected TZ current day. Adjust back + // Given date/time in midnight UTC (tab_date) apply the offset for the users selected preference + // (add offset). + if (sFSTPHistoryTZ() == "local") // local + { + tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() + LLStringOps::getLocalTimeOffset()); + } + else if (sFSTPHistoryTZ() != "utc") // slt + { + // note that SLT is a +ve offset + tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() + LLStringOps::getPacificTimeOffset()); + } + // we now have the adjusted date time which maybe a different day to the UTC day + // Note that the existing logic below is "slightly" broken. Adding "seconds_in_day" to establish "next 23:59" will be wrong for leapseconds + // however fixing it is more risky than the change warrants. + // Other edge cases can feasibily occur due to change of time during list build. not important + // tab_idx = -1; @@ -1106,6 +1154,7 @@ void LLTeleportHistoryPanel::onAccordionTabRightClick(LLView *view, S32 x, S32 y mAccordionTabMenu->setItemVisible("TabOpen", !tab->isExpanded() ? true : false); mAccordionTabMenu->setItemVisible("TabClose", tab->isExpanded() ? true : false); + mAccordionTabMenu->show(x, y); LLMenuGL::showPopup(tab, mAccordionTabMenu, x, y); } @@ -1149,6 +1198,24 @@ void LLTeleportHistoryPanel::onCollapseAllFolders() } } +// [timezone support for teleport history] +void LLTeleportHistoryPanel::onTimeZoneChecked(const LLSD& userdata) +{ + static LLCachedControl sFSTPHistoryTZ(gSavedSettings, "FSTPHistoryTZ"); + gSavedSettings.setString("FSTPHistoryTZ", userdata.asString()); + onTeleportHistoryChange(-1); // force recreate all +} + + +bool LLTeleportHistoryPanel::isTimeZoneChecked(const LLSD& userdata) +{ + static LLCachedControl sFSTPHistoryTZ(gSavedSettings, "FSTPHistoryTZ"); + + const std::string zone_string = userdata.asString(); + return ( sFSTPHistoryTZ() == zone_string); +} +// + void LLTeleportHistoryPanel::onClearTeleportHistory() { LLNotificationsUtil::add("ConfirmClearTeleportHistory", LLSD(), LLSD(), boost::bind(&LLTeleportHistoryPanel::onClearTeleportHistoryDialog, this, _1, _2)); diff --git a/indra/newview/llpanelteleporthistory.h b/indra/newview/llpanelteleporthistory.h index 579a183bcf..8fe1e32436 100644 --- a/indra/newview/llpanelteleporthistory.h +++ b/indra/newview/llpanelteleporthistory.h @@ -92,6 +92,10 @@ private: void onAccordionTabClose(LLAccordionCtrlTab *tab); void onExpandAllFolders(); void onCollapseAllFolders(); +// [timezone support for teleport history] + void onTimeZoneChecked(const LLSD& userdata); + bool isTimeZoneChecked(const LLSD& userdata); +// void onClearTeleportHistory(); bool onClearTeleportHistoryDialog(const LLSD& notification, const LLSD& response); diff --git a/indra/newview/skins/default/xui/en/menu_teleport_history_gear.xml b/indra/newview/skins/default/xui/en/menu_teleport_history_gear.xml index 134b331514..dcd36ee623 100644 --- a/indra/newview/skins/default/xui/en/menu_teleport_history_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_teleport_history_gear.xml @@ -26,7 +26,41 @@ function="TeleportHistory.GearMenu.Enable" parameter="collapse_all" /> - + + + + + + + + + + + + + + + + +