Author: mordante
Date: Sun May 27 00:06:18 2007
New Revision: 17877

URL: http://svn.gna.org/viewcvs/wesnoth?rev=17877&view=rev
Log:
rewrote timestring() so it looks better

Modified:
    trunk/src/display.cpp

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=17877&r1=17876&r2=17877&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Sun May 27 00:06:18 2007
@@ -2358,21 +2358,13 @@
 // Uses preferences::clock_format() for formatting.
 static std::string timestring ()
 {
-    #define TIME_SIZE 10
-    time_t now = time ( NULL );
-    struct tm *lt = localtime( &now );
-
-    char *tstring;
-    tstring = new char[TIME_SIZE];
-    strftime(tstring,TIME_SIZE,preferences::clock_format().c_str(),lt);
-
-    std::stringstream time_stream;
-    time_stream << tstring;
-    delete[] tstring;
-    return time_stream.str();
-    #undef TIME_SIZE
-}
-
+    time_t now = time (NULL);
+    struct tm *lt = localtime(&now);
+    char buf[10];
+    strftime(buf,sizeof(buf),preferences::clock_format().c_str(),lt);
+
+    return buf;
+}
 
 void display::debug_highlight(const gamemap::location& loc, fixed_t amount)
 {


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to