Exemplo n.º 1
1
	inline QDateTime ToQDateTime(boost::chrono::system_clock::time_point point)
	{
		auto msec = boost::chrono::duration_cast<boost::chrono::milliseconds>(point.time_since_epoch());
		return QDateTime::fromMSecsSinceEpoch(msec.count());
	}
void print_time(boost::chrono::system_clock::time_point t)
{
    using namespace boost::chrono;
    time_t c_time = system_clock::to_time_t(t);
    std::tm* tmptr = std::localtime(&c_time);
    system_clock::duration d = t.time_since_epoch();
    std::cout << tmptr->tm_hour << ':' << tmptr->tm_min << ':' << tmptr->tm_sec
              << '.' << (d - duration_cast<seconds>(d)).count();
}
Exemplo n.º 3
0
static void fillSlotsFromTime(PyrSlot * result, struct tm* tm, boost::chrono::system_clock::time_point const & now)
{
    PyrSlot *slots = slotRawObject(result)->slots;

    SetInt(slots+0, tm->tm_year + 1900);
    SetInt(slots+1, tm->tm_mon + 1); // 0 based month ??
    SetInt(slots+2, tm->tm_mday);
    SetInt(slots+3, tm->tm_hour);
    SetInt(slots+4, tm->tm_min);
    SetInt(slots+5, tm->tm_sec);
    SetInt(slots+6, tm->tm_wday);
    SetFloat(slots+7, chrono::duration_cast<chrono::nanoseconds>(now.time_since_epoch()).count() * 1.0e-9);
}
Exemplo n.º 4
0
static boost::system_time toPosixTime(const boost::chrono::system_clock::time_point& t)
{
    // Creating the posix_time using from_time_t loses sub-second precision. So rather than exporting the time_point to time_t,
    // start with a posix_time at the epoch (0) and add the milliseconds that have passed since then.
    return boost::posix_time::from_time_t(0) + boost::posix_time::milliseconds(boost::chrono::duration_cast<boost::chrono::milliseconds>(t.time_since_epoch()).count());
}
Exemplo n.º 5
0
	inline void ToQDateTime(boost::chrono::system_clock::time_point point, QDateTime & dt)
	{
		auto msec = boost::chrono::duration_cast<boost::chrono::milliseconds>(point.time_since_epoch());
		dt.setMSecsSinceEpoch(msec.count());
	}
Exemplo n.º 6
0
	inline QDate ToQDate(boost::chrono::system_clock::time_point point)
	{
		auto days = boost::chrono::duration_cast<boost::chrono::hours>(point.time_since_epoch()).count() / 24;
		return QDate::fromJulianDay(days + QDATE_JULIAN_DAY_FOR_UNIX_EPOCH);
	}