/*! * \brief 現在日時設定 */ void DateTime::setCurrent() { #if defined(_WINDOWS) SYSTEMTIME now; // GetLocalTime( &now); GetSystemTime(&now); mValue = ((uint64_t)(now.wYear - 1900) << 56) | ((uint64_t) now.wMonth << 48) | ((uint64_t) now.wDay << 40) | ((uint64_t) now.wHour << 32) | ((uint64_t) now.wMinute << 24) | ((uint64_t) now.wSecond << 16) | ((uint64_t) now.wMilliseconds ); #else #if 0 timeval tv; gettimeofday(&tv, nullptr); setTime_t(tv.tv_sec, (uint64_t)tv.tv_usec / 1000); #else timespec tv; #if (__APPLE__) clock_serv_t cs; mach_timespec_t mts; host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cs); clock_get_time(cs, &mts); mach_port_deallocate(mach_task_self(), cs); tv.tv_sec = mts.tv_sec; tv.tv_nsec = mts.tv_nsec; #else clock_gettime(CLOCK_REALTIME, &tv); #endif setTime_t(tv.tv_sec, (uint64_t)tv.tv_nsec / (1000 * 1000)); #endif #endif // defined(_WINDOWS) }
void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC ) { setTime_t( secsSince1Jan1970UTC, Qt::LocalTime ); }