コード例 #1
0
ファイル: types.cpp プロジェクト: bjwimpey/quickmsg
 Time::Time(const std::chrono::high_resolution_clock::time_point& t)
 {
   std::chrono::high_resolution_clock::duration d = t.time_since_epoch();
   secs_ = static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::seconds>(d).count());
   uint64_t micros = static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::microseconds>(d).count());
   uint64_t secs = 1e6*secs_;
   msecs_ = micros - secs;
 }
コード例 #2
0
void MovementConstraints::insertCameraConstraints(cv::Mat map,
								std::chrono::high_resolution_clock::time_point curTimestampMap,
								cv::Mat mapMove) {
	TAPAS::CameraConstraints srv;
	int map_size = MAP_SIZE*MAP_SIZE*sizeof(float);

	memcpy(srv.request.constraintsMap.data(), map.data, map_size);
	srv.request.timestamp = std::chrono::duration_cast<std::chrono::nanoseconds>(curTimestampMap.time_since_epoch()).count();
	memcpy(srv.request.mapMove.data(), mapMove.data, 16*sizeof(float));
	cameraConstraintsClient.call(srv);
	memcpy(map.data, srv.response.constraintsMap.data(), map_size);
}
コード例 #3
0
ファイル: TimeUtils.cpp プロジェクト: drashti304/TizenRT
bool TimeUtils::convertTimeToUtcIso8601Rfc3339(
    const std::chrono::high_resolution_clock::time_point& tp,
    std::string* iso8601TimeString) {
    // The length of the RFC 3339 string for the time is maximum 28 characters, include an extra byte for the '\0'
    // terminator.
    char buf[29];
    memset(buf, 0, sizeof(buf));

    // Need to assign it to time_t since time_t in some platforms is long long
    auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch());
    auto sec = std::chrono::duration_cast<std::chrono::seconds>(ms);
    const time_t timeSecs = static_cast<time_t>(sec.count());

    std::tm utcTm;
    if (!m_safeCTimeAccess->getGmtime(timeSecs, &utcTm)) {
        ACSDK_ERROR(LX("convertTimeToUtcIso8601Rfc3339").m("cannot retrieve tm struct"));
        return false;
    }

    // it's possible for std::strftime to correctly return length = 0, but not with the format string used.  In this
    // case length == 0 is an error.
    #ifndef __TizenRT__
    auto strftimeResult = std::strftime(buf, sizeof(buf) - 1, "%Y-%m-%dT%H:%M:%S", &utcTm);
    #else
    auto strftimeResult = strftime(buf, sizeof(buf) - 1, "%Y-%m-%dT%H:%M:%S", &utcTm);
    #endif
    if (strftimeResult == 0) {
        ACSDK_ERROR(LX("convertTimeToUtcIso8601Rfc3339Failed").m("strftime(..) failed"));
        return false;
    }

    std::stringstream millisecondTrailer;
    millisecondTrailer << buf << "." << std::setfill('0') << std::setw(3) << (ms.count() % 1000) << "Z";

    *iso8601TimeString = millisecondTrailer.str();
    return true;
}
コード例 #4
0
ファイル: SortingTester.cpp プロジェクト: cwbriones/sort
int SortingTester::get_ms_duration(const std::chrono::high_resolution_clock::time_point& time){
    return 
        std::chrono::duration_cast<std::chrono::milliseconds>(
                time.time_since_epoch()
            ).count();
}
コード例 #5
0
ファイル: StringUtils.cpp プロジェクト: albertowd/StringUtils
/// Format a time string in the pattern "hours:minutes:seconds.microseconds" of the console local time.
///\param std::chrono::high_resolution_clock::time_point point Time point in the highest resolution time clock.
std::string StringUtils::formatTime(std::chrono::high_resolution_clock::time_point point)
{
	return StringUtils::formatDuration(std::chrono::duration_cast<std::chrono::milliseconds>(point.time_since_epoch() % std::chrono::hours(24)), true);
}