• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ date_duration_type类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中date_duration_type的典型用法代码示例。如果您正苦于以下问题:C++ date_duration_type类的具体用法?C++ date_duration_type怎么用?C++ date_duration_type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了date_duration_type类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: subtract_days

 static time_rep_type subtract_days(const time_rep_type& base,
                                    const date_duration_type& dd)
 {
   if(base.is_special() || dd.is_special()) {
     return(time_rep_type(base.get_rep() - dd.get_rep()));
   }
   else{
     return time_rep_type(base.time_count() - (dd.days() * time_rep_type::frac_sec_per_day()));
   }
 }
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:10,代码来源:time_system_counted.hpp


示例2: utc_to_local

 template<class time_type>
 class c_local_adjustor {
 public:
   typedef typename time_type::time_duration_type time_duration_type;
   typedef typename time_type::date_type date_type;
   typedef typename date_type::duration_type date_duration_type;
   //! 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) {
       boost::throw_exception(std::out_of_range("Cannot convert dates prior to Jan 1, 1970"));
       BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return time_t_start_time); // should never reach
     }
     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);
     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:SokolovaCo,项目名称:Alfa-stock,代码行数:31,代码来源:c_local_time_adjustor.hpp


示例3: utc_to_local

 template<class time_type>
 class c_local_adjustor {
 public:
   typedef typename time_type::time_duration_type time_duration_type;
   typedef typename time_type::date_type date_type;
   typedef typename date_type::duration_type date_duration_type;
   //! 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) {
       boost::throw_exception(std::out_of_range("Cannot convert dates prior to Jan 1, 1970"));
       BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return time_t_start_time); // should never reach
     }
     date_duration_type dd = t.date() - time_t_start_day;
     time_duration_type td = t.time_of_day();
     uint64_t t2 = static_cast<uint64_t>(dd.days())*86400 +
                   static_cast<uint64_t>(td.hours())*3600 +
                   static_cast<uint64_t>(td.minutes())*60 +
                   td.seconds();
     // detect y2038 issue and throw instead of proceed with bad time
     std::time_t tv = boost::numeric_cast<std::time_t>(t2);
     std::tm tms, *tms_ptr;
     tms_ptr = c_time::localtime(&tv, &tms);
     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,
开发者ID:ASMlover,项目名称:study,代码行数:31,代码来源:c_local_time_adjustor.hpp


示例4: utc_to_local

 template<class time_type>
 class c_local_adjustor {
 public:
   typedef typename time_type::time_duration_type time_duration_type;
   typedef typename time_type::date_type date_type;
   typedef typename date_type::duration_type date_duration_type;
   //! 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) {
       boost::throw_exception(std::out_of_range("Cannot convert dates prior to Jan 1, 1970"));
       BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return time_t_start_time); // should never reach
     }
     date_duration_type dd = t.date() - time_t_start_day;
     time_duration_type td = t.time_of_day();
     std::time_t t2 = static_cast<std::time_t>(dd.days())*86400 +
                      static_cast<std::time_t>(td.hours())*3600 +
                      static_cast<std::time_t>(td.minutes())*60 +
                      td.seconds();
     std::tm tms, *tms_ptr;
     tms_ptr = c_time::localtime(&t2, &tms);
     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());
     
开发者ID:imos,项目名称:icfpc2015,代码行数:30,代码来源:c_local_time_adjustor.hpp



注:本文中的date_duration_type类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ date_period类代码示例发布时间:2022-05-31
下一篇:
C++ date类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap