append correct unit when printing Time objects
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 02 Jul 2007 19:44:18 +0200
changeset 911 de8102a51fbf
parent 788 72ea95517a13
child 912 1f600c2aec77
append correct unit when printing Time objects
src/simulator/time.cc
--- a/src/simulator/time.cc	Thu Jun 21 12:33:50 2007 +0100
+++ b/src/simulator/time.cc	Mon Jul 02 19:44:18 2007 +0200
@@ -191,7 +191,28 @@
 std::ostream& 
 operator<< (std::ostream& os, Time const& time)
 {
-  os << time.GetTimeStep () << "ts";
+  std::string unit;
+  switch (TimeStepPrecision::Get ()) {
+  case TimeStepPrecision::S:
+    unit = "s";
+    break;
+  case TimeStepPrecision::MS:
+    unit = "ms";
+    break;
+  case TimeStepPrecision::US:
+    unit = "us";
+    break;
+  case TimeStepPrecision::NS:
+    unit = "ns";
+    break;
+  case TimeStepPrecision::PS:
+    unit = "ps";
+    break;
+  case TimeStepPrecision::FS:
+    unit = "fs";
+    break;
+  }
+  os << time.GetTimeStep () << unit;
   return os;
 }