inline void setAnimationTime(const TimePoint& timePoint) { if (mode == MapMode::Still) { return; } animationTime = timePoint.time_since_epoch(); };
static inline int64 OSCTime(TimePoint const & tp) { using namespace chrono; typedef typename TimePoint::duration Duration; Duration sinceEpoch = tp.time_since_epoch(); seconds secs = duration_cast<seconds>(sinceEpoch); nanoseconds nsecs = sinceEpoch - secs; return ((int64)(secs.count() + kSECONDS_FROM_1900_to_1970) << 32) + (int64)(nsecs.count() * kNanosToOSCunits); }
jobject mdr::JniStationPrediction::createJniStationPrediction(JNIEnv *env, TimePoint timePoint, float value, std::string timeZone) { auto duration = timePoint.time_since_epoch(); auto epoch = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count(); jlong jniEpoch = static_cast<jlong>(epoch); jobject jniValue = mdr::JniFloat::toJni(env, value); jstring tz = mdr::JniString::toJni(env, timeZone); auto retVal = env->CallStaticObjectMethod(stationPredictionFactoryClass, factoryCtor, jniEpoch, tz, jniValue); mdr::Jni::checkException(env, true); return retVal; }
static inline int32 timeSeed() { using namespace chrono; static int32 count = 0; typedef high_resolution_clock::time_point TimePoint; typedef TimePoint::duration Duration; TimePoint now = high_resolution_clock::now(); Duration sinceEpoch = now.time_since_epoch(); seconds secs = duration_cast<seconds>(sinceEpoch); nanoseconds nsecs = sinceEpoch - secs; return (int32)secs.count() ^ (int32)nsecs.count() ^ count--; }
inline void print_ms(const TimePoint<Ms>& time_point) { std::cout << time_point.time_since_epoch().count() << " ms\n"; }
static inline double secondsSinceEpoch(TimePoint const & tp) { return chrono::duration_cast<chrono::nanoseconds>(tp.time_since_epoch()).count() * 1e-9; }