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(); }
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(); }
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(); }
AmfDate(std::chrono::system_clock::time_point date) { auto duration = date.time_since_epoch(); value = std::chrono::duration_cast<std::chrono::milliseconds>( duration).count(); }
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()); }
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; }
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()); }
/// 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()); }
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); }
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(); }