Esempio n. 1
0
std::string
to_string(std::chrono::system_clock::time_point tp)
{
    const char* months[] =
        {
            "Jan", "Feb", "Mar", "Apr", "May", "Jun",
            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
        };
    using namespace std::chrono;
    auto s = floor<seconds>(tp.time_since_epoch());
    auto sd = floor<days>(s);  // number of days
    s -= sd;  // time of day in seconds
    auto h = floor<hours>(s);
    s -= h;
    auto m = floor<minutes>(s);
    s -= m;
    int y;
    unsigned mn, d;
    std::tie(y, mn, d) = civil_from_days(static_cast<int>(sd.count()));
    // Date-time in y/mn/d h:m:s
    std::ostringstream str;
    str.fill('0');
    str.flags(std::ios::dec | std::ios::right);
    using std::setw;
    str << y << '-' << months[mn-1] << '-' << setw(2) << d << ' '
        << setw(2) << h.count() << ':'
        << setw(2) << m.count() << ':'
        << setw(2) << s.count();
    return str.str();
}
Esempio n. 2
0
aku_Timestamp DateTimeUtil::from_std_chrono(std::chrono::system_clock::time_point timestamp) {
    auto duration = timestamp.time_since_epoch();
    DurationT result = std::chrono::duration_cast<DurationT>(duration);
    return result.count();
}
Esempio n. 3
0
 Time from_chrono(const std::chrono::system_clock::time_point&t){
     auto now=t.time_since_epoch();
     return std::chrono::duration_cast<std::chrono::milliseconds>(now).count();
 }
Esempio n. 4
0
	AmfDate(std::chrono::system_clock::time_point date) {
		auto duration = date.time_since_epoch();
		value = std::chrono::duration_cast<std::chrono::milliseconds>(
			duration).count();
	}
Esempio n. 5
0
void ArgumentCoder<std::chrono::system_clock::time_point>::encode(IPC::Encoder& encoder, const std::chrono::system_clock::time_point& timePoint)
{
    encoder << static_cast<int64_t>(timePoint.time_since_epoch().count());
}
Esempio n. 6
0
	inline double ToJulianDay(std::chrono::system_clock::time_point point)
	{
		auto days = std::chrono::duration_cast<std::chrono::hours>(point.time_since_epoch()).count() / 24;
		return days + QDATE_JULIAN_DAY_FOR_UNIX_EPOCH;
	}
Esempio n. 7
0
	inline QDateTime ToQDateTime(std::chrono::system_clock::time_point point)
	{
		auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(point.time_since_epoch());
		return QDateTime::fromMSecsSinceEpoch(msec.count());
	}
Esempio n. 8
0
	/// QDateTime - qt shared data class, который создается на куче.
	/// предоставляем 2 версии сигнатур с in/out параметром и return формой
	inline void ToQDateTime(std::chrono::system_clock::time_point point, QDateTime & dt)
	{
		auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(point.time_since_epoch());
		dt.setMSecsSinceEpoch(msec.count());
	}
Esempio n. 9
0
void Sqlite3_Database::Sqlite3_Statement::bind(int column, std::chrono::system_clock::time_point time)
   {
   const int timeval = std::chrono::duration_cast<std::chrono::seconds>(time.time_since_epoch()).count();
   bind(column, timeval);
   }
Esempio n. 10
0
int64_t to_us(const std::chrono::system_clock::time_point &tp) {
  return std::chrono::duration_cast<std::chrono::microseconds>(tp.time_since_epoch()).count();
}