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

C++ time_type类代码示例

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

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



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

示例1: time_put

 //! Put time into an ostream 
 static void time_put(const time_type& t, 
                      ostream_type& os)
 {
   date_type d = t.date();
   os << d << " "; //TODO: fix the separator here.
   duration_formatter::duration_put(t.time_of_day(), os);
   
 } // time_to_ostream    
开发者ID:NeoAnomaly,项目名称:xray,代码行数:9,代码来源:time_formatting_streams.hpp


示例2: put

    OutItrT put(OutItrT a_next, 
                std::ios_base& a_ios, 
                char_type a_fill, 
                const time_type& a_time) const 
    {
      if (a_time.is_special()) { 
        return do_put_special(a_next, a_ios, a_fill, 
                              a_time.date().as_special());
      }
      string_type format(m_format);
      string_type frac_str;
      if (format.find(seconds_with_fractional_seconds_format)) {
        // replace %s with %S.nnn 
        frac_str = 
          fractional_seconds_as_string(a_time.time_of_day(), false);
        char_type sep = std::use_facet<std::numpunct<char_type> >(a_ios.getloc()).decimal_point();
        
        string_type replace_string(seconds_format);
        replace_string += sep;
        replace_string += frac_str;
        boost::algorithm::replace_all(format, 
                                      seconds_with_fractional_seconds_format, 
                                      replace_string);
      }
      if (format.find(fractional_seconds_format)) {
        // replace %f with nnnnnnn
        if (!frac_str.size()) {
          frac_str = fractional_seconds_as_string(a_time.time_of_day(), false);
        }
        boost::algorithm::replace_all(format,
                                      fractional_seconds_format, 
                                      frac_str);
      }

      if (format.find(fractional_seconds_or_none_format)) {
        // replace %F with nnnnnnn or nothing if fs == 0
        frac_str = 
          fractional_seconds_as_string(a_time.time_of_day(), true);
        if (frac_str.size()) {
          char_type sep = std::use_facet<std::numpunct<char_type> >(a_ios.getloc()).decimal_point();
          string_type replace_string;
          replace_string += sep;
          replace_string += frac_str;
          boost::algorithm::replace_all(format,
                                        fractional_seconds_or_none_format, 
                                        replace_string);
        }
        else {
          boost::algorithm::erase_all(format,
                                      fractional_seconds_or_none_format);
        }
      }

      return do_put_tm(a_next, a_ios, a_fill, 
                       to_tm(a_time), format);
    }
开发者ID:dmm,项目名称:cegis,代码行数:56,代码来源:time_facet.hpp


示例3: time_put

 //! Put time into an ostream 
 static void time_put(const time_type& t, 
                      ostream_type& os)
 {
   date_type d = t.date();
   os << d;
   if(!d.is_infinity() && !d.is_not_a_date())
   {
     os << " "; //TODO: fix the separator here.
     duration_formatter::duration_put(t.time_of_day(), os);
   }
   
 } // time_to_ostream    
开发者ID:jinby,项目名称:autoupdate,代码行数:13,代码来源:time_formatting_streams.hpp


示例4: local_to_utc_offset

 //! Get the offset to UTC given a local time
 static time_duration_type local_to_utc_offset(const time_type& t, 
                                               date_time::dst_flags dst=date_time::calculate) 
 { 
   switch (dst) {
   case is_dst:
     return utc_offset_rules::local_to_utc_base_offset() - dst_rules::dst_offset();
   case not_dst:
     return utc_offset_rules::local_to_utc_base_offset();
   case calculate:
     time_is_dst_result res = 
       dst_rules::local_is_dst(t.date(), t.time_of_day());
     switch(res) {
     case is_in_dst:      return utc_offset_rules::local_to_utc_base_offset() - dst_rules::dst_offset();
     case is_not_in_dst:      return utc_offset_rules::local_to_utc_base_offset();
     case ambiguous:          return utc_offset_rules::local_to_utc_base_offset();
     case invalid_time_label: throw std::out_of_range("Time label invalid");
     }
   }  
   throw std::out_of_range("Time label invalid");
 }
开发者ID:jinby,项目名称:autoupdate,代码行数:21,代码来源:local_time_adjustor.hpp


示例5: local_to_utc_offset

 //! Get the offset to UTC given a local time
 static time_duration_type local_to_utc_offset(const time_type& t, 
                                               date_time::dst_flags dst=date_time::calculate) 
 {
   switch (dst) {
   case is_dst:
     return utc_offset_rules::local_to_utc_base_offset() - dst_rules::dst_offset();
   case not_dst:
     return utc_offset_rules::local_to_utc_base_offset();
   case calculate:
     time_is_dst_result res = 
       dst_rules::local_is_dst(t.date(), t.time_of_day());
     switch(res) {
     case is_in_dst:      return utc_offset_rules::local_to_utc_base_offset() - dst_rules::dst_offset();
     case is_not_in_dst:      return utc_offset_rules::local_to_utc_base_offset();
     case ambiguous:          return utc_offset_rules::local_to_utc_base_offset();
     case invalid_time_label: break;
     }
   }
   lslboost::throw_exception(std::out_of_range("Time label invalid"));
   BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return time_duration_type(not_a_date_time)); // should never reach
 }
开发者ID:alistairwalsh,项目名称:LSL-gazzlab-branch,代码行数:22,代码来源:local_time_adjustor.hpp


示例6: 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,代码来源:c_local_time_adjustor.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ timer类代码示例发布时间:2022-05-31
下一篇:
C++ time_duration类代码示例发布时间: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