Commit in projects/slic/branches/v04-00-00-pre on MAIN | |||
include/TimeUtil.hh | +28 | -36 | 3119 -> 3120 |
src/TimeUtil.cc | -38 | 3119 removed | |
+28 | -74 |
Merge from trunk.
--- projects/slic/branches/v04-00-00-pre/include/TimeUtil.hh 2014-05-08 23:43:15 UTC (rev 3119) +++ projects/slic/branches/v04-00-00-pre/include/TimeUtil.hh 2014-05-08 23:45:20 UTC (rev 3120) @@ -1,9 +1,11 @@
// $Header: /nfs/slac/g/lcd/cvs/lcdroot/slic/include/TimeUtil.hh,v 1.12 2013-11-06 00:23:36 jeremy Exp $
-
#ifndef SLIC_TIMEUTIL_HH #define SLIC_TIMEUTIL_HH 1 // std
+#include <ctime> +#include <cstdio> +#include <iostream>
#include <string> /**
@@ -16,47 +18,37 @@
typedef long long long64;
-public:
+ static std::string getAscTime() { + tm* timeinfo = get_tm_local();
- /** - * Class destructor. - */ - virtual ~TimeUtil();
+ std::string s = asctime(timeinfo); + s.erase(s.end() - 1, s.end()); + return s; + }
-private:
+ // FIXME: This has only millisecond accuracy. + static long64 getTimeNS() { + long64 t_sec = (long64) time(NULL); + long64 t_ns = t_sec * ((long64) 1e9); + return t_ns; + }
- /** - * Class constructor, which is private because functions are all static. - */ - TimeUtil();
+ static std::string getDate() { + tm* timeinfo = get_tm_local(); + char buffer[11]; + strftime(buffer, 11, "%Y-%m-%d", timeinfo); + return std::string(buffer); + }
-public:
+ static tm* get_tm_local() { + time_t rawtime; + struct tm* timeinfo;
- /** - * Get the current date as a formmating string. - * @return The date formatted as "YYYY-MM-DD" - */ - static std::string getDate();
+ time(&rawtime); + timeinfo = localtime(&rawtime);
- /** - * Get the current ASCII time. - * @return The full time as an ASCII formatted string. - */ - static std::string getAscTime(); - - /** - * Get the time since the epoch, in nanoseconds, with a one second resolution. - * @return time since the epoch in nanoseconds. - */ - static TimeUtil::long64 getTimeNS(); - -private: - - /** - * The current timeinfo. - * @return The timeinfo processed with the localtime() function. - */ - static tm* get_tm_local();
+ return timeinfo; + }
}; #endif
--- projects/slic/branches/v04-00-00-pre/src/TimeUtil.cc 2014-05-08 23:43:15 UTC (rev 3119) +++ projects/slic/branches/v04-00-00-pre/src/TimeUtil.cc 2014-05-08 23:45:20 UTC (rev 3120) @@ -1,38 +0,0 @@
-// $Header: /nfs/slac/g/lcd/cvs/lcdroot/slic/src/TimeUtil.cc,v 1.10 2012-11-27 19:32:19 jeremy Exp $ -#include "TimeUtil.hh" - -// std -#include <ctime> -#include <cstdio> -#include <iostream> - -std::string TimeUtil::getAscTime() { - tm* timeinfo = get_tm_local(); - - std::string s = asctime(timeinfo); - s.erase(s.end() - 1, s.end()); - return s; -} - -TimeUtil::long64 TimeUtil::getTimeNS() { - long64 t_sec = (long64) time(NULL); - long64 t_ns = t_sec * ((long64) 1e9); - return t_ns; -} - -std::string TimeUtil::getDate() { - tm* timeinfo = get_tm_local(); - char buffer[11]; - strftime(buffer, 11, "%Y-%m-%d", timeinfo); - return std::string(buffer); -} - -tm* TimeUtil::get_tm_local() { - time_t rawtime; - struct tm* timeinfo; - - time(&rawtime); - timeinfo = localtime(&rawtime); - - return timeinfo; -}
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1