这篇教程C++ time_type函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中time_type函数的典型用法代码示例。如果您正苦于以下问题:C++ time_type函数的具体用法?C++ time_type怎么用?C++ time_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了time_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: create_time static time_type create_time(TZ_FOR_CREATE tz) { timeval tv; gettimeofday(&tv, 0); //gettimeofday does not support TZ adjust on Linux. std::time_t t = tv.tv_sec; boost::uint32_t fs = tv.tv_usec; std::tm curr, *curr_ptr = 0; if (tz == LOCAL) { curr_ptr = c_time::localtime(&t, &curr); } else { curr_ptr = c_time::gmtime(&t, &curr); } date_type d(curr_ptr->tm_year + 1900, curr_ptr->tm_mon + 1, curr_ptr->tm_mday); //The following line will adjusts the fractional second tick in terms //of the current time system. For example, if the time system //doesn't support fractional seconds then res_adjust returns 0 //and all the fractional seconds return 0. int adjust = resolution_traits_type::res_adjust()/1000000; time_duration_type td(curr_ptr->tm_hour, curr_ptr->tm_min, curr_ptr->tm_sec, fs*adjust); return time_type(d,td); }
开发者ID:Albermg7,项目名称:boost,代码行数:27,
示例2: m_expiration_time high_resolution_timer::high_resolution_timer(io_service& io_service, const duration_type& expiry_time) : m_expiration_time(time_type()) , m_io_service(io_service) , m_expired(true) { expires_from_now(expiry_time); }
开发者ID:arvidn,项目名称:libsimulator,代码行数:8,
示例3: create_time static time_type create_time(::std::tm* current) { date_type d(static_cast<unsigned short>(current->tm_year + 1900), static_cast<unsigned short>(current->tm_mon + 1), static_cast<unsigned short>(current->tm_mday)); time_duration_type td(current->tm_hour, current->tm_min, current->tm_sec); return time_type(d,td); }
开发者ID:SokolovaCo,项目名称:Alfa-stock,代码行数:10,
示例4: local_time static time_type local_time(shared_ptr<time_zone_type> tz_ptr) { typedef typename time_type::utc_time_type utc_time_type; typedef second_clock<utc_time_type> second_clock; // we'll need to know the utc_offset this machine has // in order to get a utc_time_type set to utc utc_time_type utc_time = second_clock::universal_time(); time_duration_type utc_offset = second_clock::local_time() - utc_time; // use micro clock to get a local time with sub seconds // and adjust it to get a true utc time reading with sub seconds utc_time = microsec_clock<utc_time_type>::local_time() - utc_offset; return time_type(utc_time, tz_ptr); }
开发者ID:Albermg7,项目名称:boost,代码行数:12,
示例5: create_time static time_type create_time(time_converter converter) {#ifdef BOOST_HAS_GETTIMEOFDAY timeval tv; gettimeofday(&tv, 0); //gettimeofday does not support TZ adjust on Linux. std::time_t t = tv.tv_sec; boost::uint32_t sub_sec = tv.tv_usec;#elif defined(BOOST_HAS_FTIME) boost::winapi::FILETIME_ ft; boost::winapi::GetSystemTimeAsFileTime(&ft);#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) // Some runtime library implementations expect local times as the norm for ctime functions. { boost::winapi::FILETIME_ local_ft; boost::winapi::FileTimeToLocalFileTime(&ft, &local_ft); ft = local_ft; }#endif boost::uint64_t micros = file_time_to_microseconds(ft); // it will not wrap, since ft is the current time // and cannot be before 1970-Jan-01 std::time_t t = static_cast<std::time_t>(micros / 1000000UL); // seconds since epoch // microseconds -- static casts suppress warnings boost::uint32_t sub_sec = static_cast<boost::uint32_t>(micros % 1000000UL);#else#error Internal Boost.DateTime error: BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK is defined, however neither gettimeofday nor FILETIME support is detected.#endif std::tm curr; std::tm* curr_ptr = converter(&t, &curr); date_type d(static_cast< typename date_type::year_type::value_type >(curr_ptr->tm_year + 1900), static_cast< typename date_type::month_type::value_type >(curr_ptr->tm_mon + 1), static_cast< typename date_type::day_type::value_type >(curr_ptr->tm_mday)); //The following line will adjust the fractional second tick in terms //of the current time system. For example, if the time system //doesn't support fractional seconds then res_adjust returns 0 //and all the fractional seconds return 0. int adjust = static_cast< int >(resolution_traits_type::res_adjust() / 1000000); time_duration_type td(static_cast< typename time_duration_type::hour_type >(curr_ptr->tm_hour), static_cast< typename time_duration_type::min_type >(curr_ptr->tm_min), static_cast< typename time_duration_type::sec_type >(curr_ptr->tm_sec), sub_sec * adjust); return time_type(d,td); }
开发者ID:DanielaE,项目名称:boost.date_time,代码行数:47,
示例6: parse_iso_time inline time_type parse_iso_time(const std::string& s, char sep) { typedef typename time_type::time_duration_type time_duration; typedef typename time_type::date_type date_type; //split date/time on a unique delimiter char such as ' ' or 'T' std::string date_string, tod_string; split(s, sep, date_string, tod_string); //call parse_date with first string date_type d = parse_undelimited_date<date_type>(date_string); //call parse_time_duration with remaining string time_duration td = parse_undelimited_time_duration<time_duration>(tod_string); //construct a time return time_type(d, td); }
开发者ID:ArthurHenriqueDellaFraga,项目名称:INE5426.Compiladores,代码行数:17,
示例7: create_time static time_type create_time(FILETIME& ft, TZ_FOR_CREATE tz) { // offset is difference (in 100-nanoseconds) from // 1970-Jan-01 to 1601-Jan-01 boost::uint64_t c1 = 27111902; boost::uint64_t c2 = 3577643008UL; // 'UL' removes compiler warnings const boost::uint64_t OFFSET = (c1 << 32) + c2; boost::uint64_t filetime = ft.dwHighDateTime; filetime = filetime << 32; filetime += ft.dwLowDateTime; filetime -= OFFSET; // filetime now holds 100-nanoseconds since 1970-Jan-01 // microseconds -- static casts supress warnings boost::uint32_t sub_sec = static_cast<boost::uint32_t>((filetime % 10000000) / 10); std::time_t t = static_cast<time_t>(filetime / 10000000); // seconds since epoch std::tm curr, *curr_ptr = 0; if (tz == LOCAL) { curr_ptr = c_time::localtime(&t, &curr); } else { curr_ptr = c_time::gmtime(&t, &curr); } date_type d(curr_ptr->tm_year + 1900, curr_ptr->tm_mon + 1, curr_ptr->tm_mday); //The following line will adjusts the fractional second tick in terms //of the current time system. For example, if the time system //doesn't support fractional seconds then res_adjust returns 0 //and all the fractional seconds return 0. int adjust = static_cast<int>(resolution_traits_type::res_adjust()/1000000); time_duration_type td(curr_ptr->tm_hour, curr_ptr->tm_min, curr_ptr->tm_sec, sub_sec * adjust); //st.wMilliseconds * adjust); return time_type(d,td); }
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:43,
示例8: create_time static time_type create_time(timeval* tv) { time_t t = tv->tv_sec; boost::uint32_t fs = tv->tv_usec; ::std::time(&t); tm* curr = localtime(&t); date_type d(curr->tm_year + 1900, curr->tm_mon + 1, curr->tm_mday); //The following line will adjusts the fractional second tick in terms //of the current time system. For example, if the time system //doesn't support fractional seconds then res_adjust returns 0 //and all the fractional seconds return 0. int adjust = resolution_traits_type::res_adjust()/1000000; time_duration_type td(curr->tm_hour, curr->tm_min, curr->tm_sec, fs*adjust); return time_type(d,td); }
开发者ID:2asoft,项目名称:xray-16,代码行数:21,
示例9: create_time static time_type create_time(time_converter converter) {#ifdef BOOST_HAS_GETTIMEOFDAY timeval tv; gettimeofday(&tv, 0); //gettimeofday does not support TZ adjust on Linux. std::time_t t = tv.tv_sec; pdalboost::uint32_t sub_sec = tv.tv_usec;#elif defined(BOOST_HAS_FTIME) winapi::file_time ft; winapi::get_system_time_as_file_time(ft); uint64_t micros = winapi::file_time_to_microseconds(ft); // it will not wrap, since ft is the current time // and cannot be before 1970-Jan-01 std::time_t t = static_cast<std::time_t>(micros / 1000000UL); // seconds since epoch // microseconds -- static casts suppress warnings pdalboost::uint32_t sub_sec = static_cast<pdalboost::uint32_t>(micros % 1000000UL);#else#error Internal Boost.DateTime error: BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK is defined, however neither gettimeofday nor FILETIME support is detected.#endif std::tm curr; std::tm* curr_ptr = converter(&t, &curr); date_type d(static_cast< typename date_type::year_type::value_type >(curr_ptr->tm_year + 1900), static_cast< typename date_type::month_type::value_type >(curr_ptr->tm_mon + 1), static_cast< typename date_type::day_type::value_type >(curr_ptr->tm_mday)); //The following line will adjust the fractional second tick in terms //of the current time system. For example, if the time system //doesn't support fractional seconds then res_adjust returns 0 //and all the fractional seconds return 0. int adjust = static_cast< int >(resolution_traits_type::res_adjust() / 1000000); time_duration_type td(static_cast< typename time_duration_type::hour_type >(curr_ptr->tm_hour), static_cast< typename time_duration_type::min_type >(curr_ptr->tm_min), static_cast< typename time_duration_type::sec_type >(curr_ptr->tm_sec), sub_sec * adjust); return time_type(d,td); }
开发者ID:EricAlex,项目名称:PDAL,代码行数:38,
示例10: time_from_ftime inline time_type time_from_ftime(const FILETIME& ft){ typedef typename time_type::date_type date_type; typedef typename time_type::date_duration_type date_duration_type; typedef typename time_type::time_duration_type time_duration_type; /* OFFSET is difference between 1970-Jan-01 & 1601-Jan-01 * in 100-nanosecond intervals */ uint64_t c1 = 27111902UL; uint64_t c2 = 3577643008UL; // issues warning without 'UL' const uint64_t OFFSET = (c1 << 32) + c2; const long sec_pr_day = 86400; // seconds per day uint64_t filetime = ft.dwHighDateTime; filetime <<= 32; filetime += ft.dwLowDateTime; filetime -= OFFSET; // filetime is now 100-nanos since 1970-Jan-01 uint64_t sec = filetime / 10000000;#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG) uint64_t sub_sec = (filetime % 10000000) * 100; // nanoseconds#else uint64_t sub_sec = (filetime % 10000000) / 10; // truncate to microseconds#endif // split sec into usable chunks: days, hours, minutes, & seconds long _d = sec / sec_pr_day; long tmp = sec % sec_pr_day; long _h = tmp / 3600; // sec_pr_hour tmp %= 3600; long _m = tmp / 60; // sec_pr_min tmp %= 60; long _s = tmp; // seconds date_duration_type dd(_d); date_type d = date_type(1970, Jan, 01) + dd; return time_type(d, time_duration_type(_h, _m, _s, sub_sec)); }
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:38,
示例11: utc_to_local //! Convert a utc time to local time static time_type utc_to_local(const time_type& t) { date_type time_t_start_day(1970,1,1); time_type time_t_start_time(time_t_start_day,time_duration_type(0,0,0)); if (t < time_t_start_time) { throw std::out_of_range("Cannot convert dates prior to Jan 1, 1970"); } date_duration_type dd = t.date() - time_t_start_day; time_duration_type td = t.time_of_day(); std::time_t t2 = dd.days()*86400 + td.hours()*3600 + td.minutes()*60 + td.seconds(); std::tm tms, *tms_ptr; tms_ptr = c_time::localtime(&t2, &tms); //tms_ptr = std::localtime(&t2); date_type d(static_cast<unsigned short>(tms_ptr->tm_year + 1900), static_cast<unsigned short>(tms_ptr->tm_mon + 1), static_cast<unsigned short>(tms_ptr->tm_mday)); time_duration_type td2(tms_ptr->tm_hour, tms_ptr->tm_min, tms_ptr->tm_sec, t.time_of_day().fractional_seconds()); return time_type(d,td2); }
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:24,
示例12: create_time static time_type create_time(FILETIME& ft) { // offset is difference (in 100-nanoseconds) from // 1970-Jan-01 to 1601-Jan-01 boost::uint64_t c1 = 27111902; boost::uint64_t c2 = 3577643008UL; // 'UL' removes compiler warnings const boost::uint64_t OFFSET = (c1 << 32) + c2; boost::uint64_t filetime = ft.dwHighDateTime; filetime = filetime << 32; filetime += ft.dwLowDateTime; filetime -= OFFSET; // filetime now holds 100-nanoseconds since 1970-Jan-01 boost::uint32_t sub_sec = (filetime % 10000000) / 10; // microseconds time_t t; ::std::time(&t); tm* curr = localtime(&t); date_type d(curr->tm_year + 1900, curr->tm_mon + 1, curr->tm_mday); //The following line will adjusts the fractional second tick in terms //of the current time system. For example, if the time system //doesn't support fractional seconds then res_adjust returns 0 //and all the fractional seconds return 0. int adjust = resolution_traits_type::res_adjust()/1000000; time_duration_type td(curr->tm_hour, curr->tm_min, curr->tm_sec, sub_sec * adjust); //st.wMilliseconds * adjust); return time_type(d,td); }
开发者ID:dmm,项目名称:cegis,代码行数:36,
示例13: local_time static time_type local_time(boost::shared_ptr<time_zone_type> tz_ptr) { typedef typename time_type::utc_time_type utc_time_type; utc_time_type utc_time = second_clock<utc_time_type>::universal_time(); return time_type(utc_time, tz_ptr); }
开发者ID:SokolovaCo,项目名称:Alfa-stock,代码行数:6,
示例14: expires_at /** * @return An absolute time value representing the stream buffer's expiry * time. */ time_type expires_at() const { return timer_service_ ? timer_service_->expires_at(timer_implementation_) : time_type(); }
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:10,
示例15: time_type timer::time_type timer::expires_at() const { return time_type(); }
开发者ID:TorstenRobitzki,项目名称:Sioux,代码行数:4,
注:本文中的time_type函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ time_update函数代码示例 C++ time_to_jiffies函数代码示例 |