예제 #1
0
파일: f8utils.cpp 프로젝트: BoSiC/fix8
//-------------------------------------------------------------------------------------------------
const string& GetTimeAsStringMini(string& result, const Tickval *tv)
{
   const Tickval *startTime;
   Tickval gotTime;
   if (tv)
      startTime = tv;
   else
   {
		gotTime.now();
      startTime = &gotTime;
   }

#ifdef _MSC_VER
   time_t tval(startTime->secs());
   struct tm *ptim(localtime (&tval));
#else
   struct tm tim, *ptim;
   time_t tval(startTime->secs());
   localtime_r(&tval, &tim);
   ptim = &tim;
#endif

// 14-07-02 23:15:51
   ostringstream oss;
   oss << setfill('0') << setw(2) << ((ptim->tm_year + 1900) % 100) << '-';
   oss << setw(2) << (ptim->tm_mon + 1)  << '-' << setw(2) << ptim->tm_mday << ' ' << setw(2) << ptim->tm_hour;
   oss << ':' << setw(2) << ptim->tm_min << ':' << setfill('0') << setw(2) << ptim->tm_sec;
   return result = oss.str();
}
예제 #2
0
파일: f8utils.cpp 프로젝트: BoSiC/fix8
//-------------------------------------------------------------------------------------------------
const string& GetTimeAsStringMS(string& result, const Tickval *tv, const unsigned dplaces, bool use_gm)
{
   const Tickval *startTime;
   Tickval gotTime;
   if (tv)
      startTime = tv;
   else
   {
		gotTime.now();
      startTime = &gotTime;
   }

#ifdef _MSC_VER
   time_t tval(startTime->secs());
   struct tm *ptim(use_gm ? gmtime(&tval) : localtime (&tval));
#else
   struct tm tim, *ptim;
   time_t tval(startTime->secs());
   use_gm ? gmtime_r(&tval, &tim) : localtime_r(&tval, &tim);
   ptim = &tim;
#endif

	// 2014-07-02 23:15:51.514776595
   ostringstream oss;
   oss << setfill('0') << setw(4) << (ptim->tm_year + 1900) << '-';
   oss << setw(2) << (ptim->tm_mon + 1)  << '-' << setw(2) << ptim->tm_mday << ' ' << setw(2) << ptim->tm_hour;
   oss << ':' << setw(2) << ptim->tm_min << ':';
	if (dplaces)
	{
		const double secs((startTime->secs() % 60) + static_cast<double>(startTime->nsecs()) / Tickval::billion);
		oss.setf(ios::showpoint);
		oss.setf(ios::fixed);
		oss << setw(3 + dplaces) << setfill('0') << setprecision(dplaces) << secs;
	}
	else
		oss << setfill('0') << setw(2) << ptim->tm_sec;
   return result = oss.str();
}
예제 #3
0
파일: timer.hpp 프로젝트: capitalk/fix8
	/*! Reset the interval start time.
	  \return the old delta as double */
   double Reset()
   {
      const double curr(AsDouble());
		startTime_.now();
      return curr;
   }
예제 #4
0
파일: timer.hpp 프로젝트: capitalk/fix8
	/*! Get delta as a double.
	  \return delta as double */
   double AsDouble() const { return delta_.todouble(); }