From 82c9301797aae0e8355213827b1e6cbfe0648a39 Mon Sep 17 00:00:00 2001
From: Josh Blum <josh@joshknows.com>
Date: Sat, 22 Jan 2011 20:48:57 -0800
Subject: qtgui: use the posix time to_simple_string to simplify label text

---
 gr-qtgui/src/lib/WaterfallDisplayPlot.cc | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

(limited to 'gr-qtgui/src')

diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc
index dc8d7b7ac4..694dc86d8d 100644
--- a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc
+++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc
@@ -13,6 +13,7 @@
 #include <qapplication.h>
 
 #include <boost/date_time/posix_time/posix_time.hpp>
+namespace pt = boost::posix_time;
 
 class FreqOffsetAndPrecisionClass
 {
@@ -137,15 +138,9 @@ public:
 
   virtual QwtText label(double value) const
   {
-    QwtText returnLabel("");
-
     timespec lineTime = timespec_add(GetZeroTime(), (-value) * GetSecondsPerLine());
-    tm timeTm(boost::posix_time::to_tm(boost::posix_time::from_time_t(lineTime.tv_sec)));
-    returnLabel = (QString("").sprintf("%04d/%02d/%02d\n%02d:%02d:%02d.%03ld",
-				       timeTm.tm_year+1900, timeTm.tm_mon+1,
-				       timeTm.tm_mday, timeTm.tm_hour, timeTm.tm_min,
-				       timeTm.tm_sec, lineTime.tv_nsec/1000000));
-    return returnLabel;
+    std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec));
+    return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000));
   }
 
   virtual void initiateUpdate()
@@ -190,14 +185,9 @@ protected:
   using QwtPlotZoomer::trackerText;
   virtual QwtText trackerText( const QwtDoublePoint& p ) const 
   {
-    QString yLabel("");
-
     timespec lineTime = timespec_add(GetZeroTime(), (-p.y()) * GetSecondsPerLine());
-    tm timeTm(boost::posix_time::to_tm(boost::posix_time::from_time_t(lineTime.tv_sec)));
-    yLabel = (QString("").sprintf("%04d/%02d/%02d %02d:%02d:%02d.%03ld",
-				  timeTm.tm_year+1900, timeTm.tm_mon+1,
-				  timeTm.tm_mday, timeTm.tm_hour, timeTm.tm_min,
-				  timeTm.tm_sec, lineTime.tv_nsec/1000000));
+    std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec));
+    QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000));
 
     QwtText t(QString("%1 %2, %3").
 	      arg(p.x(), 0, 'f', GetFrequencyPrecision()).
-- 
cgit v1.2.3