当前位置: 首页>>代码示例>>C++>>正文


C++ time_type::time_of_day方法代码示例

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


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

示例1: 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

示例2: 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

示例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: 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

示例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: throw std::out_of_range("Time label invalid");
     }
   }  
   throw std::out_of_range("Time label invalid");
 }
开发者ID:jinby,项目名称:autoupdate,代码行数:21,代码来源:local_time_adjustor.hpp

示例6: 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


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