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


C++ date_type::year_month_day方法代码示例

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


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

示例1: get_neg_offset

 //! Returns a negative duration_type
 duration_type get_neg_offset(const date_type& d) const 
 {
   ymd_type ymd(d.year_month_day());
   if (origDayOfMonth_ == 0) {
     origDayOfMonth_ = ymd.day;
     day_type endOfMonthDay(cal_type::end_of_month_day(ymd.year,ymd.month));
     if (endOfMonthDay == ymd.day) {
       origDayOfMonth_ = -1; //force the value to the end of month
     }
   }
   typedef date_time::wrapping_int2<short,1,12> wrap_int2;
   typedef typename wrap_int2::int_type int_type;
   wrap_int2 wi(ymd.month);
   //calc the year wrap around, add() returns 0 or 1 if wrapped
   int_type year = wi.subtract(static_cast<int_type>(f_)); 
   year = static_cast<int_type>(year + ymd.year); //calculate resulting year
   //find the last day for the new month
   day_type resultingEndOfMonthDay(cal_type::end_of_month_day(year, wi.as_int()));
   //original was the end of month -- force to last day of month
   if (origDayOfMonth_ == -1) {
     return date_type(year, wi.as_int(), resultingEndOfMonthDay) - d;
   }
   day_type dayOfMonth = origDayOfMonth_;
   if (dayOfMonth > resultingEndOfMonthDay) {
     dayOfMonth = resultingEndOfMonthDay;
   }
   return date_type(year, wi.as_int(), dayOfMonth) - d;
 }
开发者ID:TheRyaz,项目名称:c_reading,代码行数:29,代码来源:adjust_functors.hpp

示例2: date_put

 //! Put date into an ostream
 static void date_put(const date_type& d,
                      ostream_type& os,
                      const facet_type& f)
 {
   special_values sv = d.as_special();
   if (sv == not_special) {
     ymd_type ymd = d.year_month_day();
     ostream_ymd_formatter<ymd_type, facet_type, charT>::ymd_put(ymd, os, f);
   }
   else { // output a special value
     std::ostreambuf_iterator<charT> coi(os);
     f.put_special_value(coi, sv);
   }
 }
开发者ID:BalticPinguin,项目名称:libmesh,代码行数:15,代码来源:date_formatting_locales.hpp

示例3: not_a_date

 //! Convert to a date to standard string using format policies
 static std::string date_to_string(date_type d)
 {
   typedef typename date_type::ymd_type ymd_type;
   if (d.is_not_a_date()) {
     return format_type::not_a_date();
   }
   if (d.is_neg_infinity()) {
     return format_type::neg_infinity();
   }
   if (d.is_pos_infinity()) {
     return format_type::pos_infinity();
   }
   ymd_type ymd = d.year_month_day();
   return ymd_formatter<ymd_type, format_type>::ymd_to_string(ymd);
 }    
开发者ID:xuanyuantd,项目名称:ToolsBuilder,代码行数:16,代码来源:date_formatting_limited.hpp


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