@@ -80,8 +80,8 @@ const static std::string MULTI_LINE_PREFIX(" ");
8080 *
8181 * Note: "You" was used as an avatar names in viewers of previous versions
8282 */
83- const static boost::regex TIMESTAMP_AND_STUFF (" ^(\\ [\\ d{4}/\\ d{1,2}/\\ d{1,2}\\ s+\\ d{1,2}:\\ d{2}\\ ]\\ s+|\\ [\\ d{1,2}:\\ d{2}\\ ]\\ s+)?(.*)$" );
84- const static boost::regex TIMESTAMP (" ^(\\ [\\ d{4}/\\ d{1,2}/\\ d{1,2}\\ s+\\ d{1,2}:\\ d{2}\\ ] |\\ [\\ d{1,2}:\\ d{2}\\ ]).*" );
83+ const static boost::regex TIMESTAMP_AND_STUFF (" ^(\\ [\\ d{4}/\\ d{1,2}/\\ d{1,2}\\ s+\\ d{1,2}:\\ d{2}\\ s[AaPp][Mm] \\ ] \\ s+| \\ [ \\ d{4}/ \\ d{1,2}/ \\ d{1,2} \\ s+ \\ d{1,2}: \\ d{2} \\ ] \\ s+| \\ [ \\ d{1,2}: \\ d{2} \\ s[AaPp][Mm] \\ ]\\ s+|\\ [\\ d{1,2}:\\ d{2}\\ ]\\ s+)?(.*)$" );
84+ const static boost::regex TIMESTAMP (" ^(\\ [\\ d{4}/\\ d{1,2}/\\ d{1,2}\\ s+\\ d{1,2}:\\ d{2}( \\ s[AaPp][Mm])? \\ ] |\\ [\\ d{1,2}:\\ d{2}( \\ s[AaPp][Mm])? \\ ]).*" );
8585
8686/* *
8787 * Regular expression suitable to match names like
@@ -152,6 +152,10 @@ class LLLogChatTimeScanner: public LLSingleton<LLLogChatTimeScanner>
152152
153153 void checkAndCutOffDate (std::string& time_str)
154154 {
155+ if (time_str.size () < 10 ) // not enough space for a date
156+ {
157+ return ;
158+ }
155159 // Cuts off the "%Y/%m/%d" from string for todays timestamps.
156160 // Assume that passed string has at least "%H:%M" time format.
157161 date log_date (not_a_date_time);
@@ -168,20 +172,12 @@ class LLLogChatTimeScanner: public LLSingleton<LLLogChatTimeScanner>
168172
169173 if ( days_alive == zero_days )
170174 {
171- // Yep, today's so strip "%Y/%m/%d" info
172- ptime stripped_time (not_a_date_time);
173-
174- mTimeStream .str (LLStringUtil::null);
175- mTimeStream << time_str;
176- mTimeStream >> stripped_time;
177- mTimeStream .clear ();
178-
179- time_str.clear ();
180-
181- mTimeStream .str (LLStringUtil::null);
182- mTimeStream << stripped_time;
183- mTimeStream >> time_str;
184- mTimeStream .clear ();
175+ size_t pos = time_str.find_first_of (' ' );
176+ if (pos != std::string::npos)
177+ {
178+ time_str.erase (0 , pos + 1 );
179+ LLStringUtil::trim (time_str);
180+ }
185181 }
186182
187183 LL_DEBUGS (" LLChatLogParser" )
@@ -310,16 +306,22 @@ std::string LLLogChat::timestamp2LogString(U32 timestamp, bool withdate)
310306 std::string timeStr;
311307 if (withdate)
312308 {
313- timeStr = " [" + LLTrans::getString (" TimeYear" ) + " ]/["
314- + LLTrans::getString (" TimeMonth" ) + " ]/["
315- + LLTrans::getString (" TimeDay" ) + " ] ["
316- + LLTrans::getString (" TimeHour" ) + " ]:["
317- + LLTrans::getString (" TimeMin" ) + " ]" ;
309+ timeStr = " [" + LLTrans::getString (" TimeYear" ) + " ]/["
310+ + LLTrans::getString (" TimeMonth" ) + " ]/["
311+ + LLTrans::getString (" TimeDay" ) + " ] " ;
312+ }
313+
314+ static bool use_24h = gSavedSettings .getBOOL (" Use24HourClock" );
315+ if (use_24h)
316+ {
317+ timeStr += " [" + LLTrans::getString (" TimeHour" ) + " ]:["
318+ + LLTrans::getString (" TimeMin" ) + " ]" ;
318319 }
319320 else
320321 {
321- timeStr = " [" + LLTrans::getString (" TimeHour" ) + " ]:["
322- + LLTrans::getString (" TimeMin" )+" ]" ;
322+ timeStr += " [" + LLTrans::getString (" TimeHour12" ) + " ]:["
323+ + LLTrans::getString (" TimeMin" ) + " ] ["
324+ + LLTrans::getString (" TimeAMPM" ) + " ]" ;
323325 }
324326
325327 LLSD substitution;
0 commit comments