예제 #1
0
void save_td(Archive& ar, const posix_time::time_duration& td)
{
    TimeResTraitsSize h = boost::numeric_cast<TimeResTraitsSize>(td.hours());
    TimeResTraitsSize m = boost::numeric_cast<TimeResTraitsSize>(td.minutes());
    TimeResTraitsSize s = boost::numeric_cast<TimeResTraitsSize>(td.seconds());
    posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
    ar & make_nvp("time_duration_hours", h);
    ar & make_nvp("time_duration_minutes", m);
    ar & make_nvp("time_duration_seconds", s);
    ar & make_nvp("time_duration_fractional_seconds", fs);
}
void save(Archive & ar, 
          const posix_time::time_duration& td, 
          unsigned int version)
{
  typename posix_time::time_duration::hour_type h = td.hours();
  typename posix_time::time_duration::min_type m = td.minutes();
  typename posix_time::time_duration::sec_type s = td.seconds();
  typename posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
  ar & make_nvp("time_duration_hours", h);
  ar & make_nvp("time_duration_minutes", m);
  ar & make_nvp("time_duration_seconds", s);
  ar & make_nvp("time_duration_fractional_seconds", fs);
}
예제 #3
0
static int getMicroseconds( const posix_time::time_duration &dur )
{
	static long ticksPerSecond = posix_time::time_duration::ticks_per_second();
	long fractionalSeconds = dur.fractional_seconds();

	static const int oneMillion = 1000000;

	/// Prevent over/underflow
	if ( ticksPerSecond > oneMillion )
	{
		return fractionalSeconds / ( ticksPerSecond / oneMillion );
	}
	else
	{
		return fractionalSeconds * ( oneMillion / ticksPerSecond );
	}
}
예제 #4
0
void save(Archive & ar, 
          const posix_time::time_duration& td, 
          unsigned int /*version*/)
{
  // serialize a bool so we know how to read this back in later
  bool is_special = td.is_special();
  ar & make_nvp("is_special", is_special);
  if(is_special) {
    std::string s = to_simple_string(td);
    ar & make_nvp("sv_time_duration", s);
  }
  else {
    typename posix_time::time_duration::hour_type h = td.hours();
    typename posix_time::time_duration::min_type m = td.minutes();
    typename posix_time::time_duration::sec_type s = td.seconds();
    typename posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
    ar & make_nvp("time_duration_hours", h);
    ar & make_nvp("time_duration_minutes", m);
    ar & make_nvp("time_duration_seconds", s);
    ar & make_nvp("time_duration_fractional_seconds", fs);
  }
}