From 9b0db769b9d9331a642d4a449f8005d73fb5b6c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mart=C3=AD=20Morta=20Garriga?= <mmorta@iri.upc.edu>
Date: Thu, 1 Sep 2011 14:36:05 +0000
Subject: [PATCH] Added more resolution to getTimeInSeconds function

---
 src/examples/test_time.cpp | 2 +-
 src/time/ctime.cpp         | 2 +-
 src/time/ctime.h           | 7 +++----
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/examples/test_time.cpp b/src/examples/test_time.cpp
index 1e640a9..7ebea9e 100644
--- a/src/examples/test_time.cpp
+++ b/src/examples/test_time.cpp
@@ -273,7 +273,7 @@ int main(void)
     t2.useRef(true);
     t2.set();
     cout << "    t2:       " << t2 << "  Is ref used?: " << t2.isRefUsed() << endl << endl;
-
+    cout << "    t2:       " << t2.getTimeInSeconds() << endl;
 
   cout << "\n  Example: END\n\n";
 
diff --git a/src/time/ctime.cpp b/src/time/ctime.cpp
index 720ff23..29efe06 100644
--- a/src/time/ctime.cpp
+++ b/src/time/ctime.cpp
@@ -62,7 +62,7 @@ unsigned long CTime::nanoseconds(void)
 
 double CTime::getTimeInSeconds(void)
 {
-  return (double)(this->sec) + this->nsec/1000000000;
+  return (double)this->sec + (double)this->nsec/1000000000;
 }
 
 // IN MILLISECONDS (1234)
diff --git a/src/time/ctime.h b/src/time/ctime.h
index dac29fd..d2d13a2 100644
--- a/src/time/ctime.h
+++ b/src/time/ctime.h
@@ -181,11 +181,10 @@ class CTime
     /**
       * \brief Get time in seconds
       *
-      * This function returns the internal time in seconds with milliseconds
-      * resolution.
+      * This function returns the internal time as a double seconds.nanoseconds.
+      * If this value is very high the resolution after the comma could be changed
       *
-      * \return the internal time in seconds with milliseconds resolution (only
-      *         the first 3 decimal places have real meaning)
+      * \return the internal time in seconds
       *
       */
     double getTimeInSeconds(void);
-- 
GitLab