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

C++ date类代码示例

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

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



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

示例1: switch

date dateUtil::dayRollAdjust(date aDate,DayRollEnum aDayRollConvention, enums::CurrencyEnum market) {
	long adjustedJDN;
	switch(aDayRollConvention){
	case enums::Following:
		adjustedJDN = getFolloingJDN(aDate, market);
		break;
	case enums::Preceding:
		adjustedJDN = getPrecedingJDN(aDate, market);
		break;
	case enums::Mfollowing:
		adjustedJDN = getFolloingJDN(aDate, market);
		if (getYearMonthDay(adjustedJDN)[1]!=aDate.getMonth())
			adjustedJDN = getPrecedingJDN(aDate, market);
		break;
	case enums::Mfollowingbi:	
		adjustedJDN = getFolloingJDN(aDate, market);
		if (getYearMonthDay(adjustedJDN)[1]!=aDate.getMonth()||
			getYearMonthDay(adjustedJDN)[2]>=15)
			adjustedJDN = getPrecedingJDN(aDate, market);
		break;
	case enums::EOM:
		break;
	case enums::DayRollNull:
		adjustedJDN = aDate.getJudianDayNumber();
		break;
	}
	date adjustedDate(adjustedJDN);
	return adjustedDate;
}
开发者ID:Neoracle,项目名称:DymonRepo,代码行数:29,代码来源:dateUtil.cpp


示例2: to_tm

//! Converts a date to a tm struct. Throws out_of_range exception if date is a special value
inline
std::tm to_tm(const date& d)
{
    if (d.is_special())
    {
        std::string s = "tm unable to handle ";
        switch (d.as_special())
        {
        case date_time::not_a_date_time:
            s += "not-a-date-time value";
            break;
        case date_time::neg_infin:
            s += "-infinity date value";
            break;
        case date_time::pos_infin:
            s += "+infinity date value";
            break;
        default:
            s += "a special date value";
            break;
        }
        boost::throw_exception(std::out_of_range(s));
    }

    std::tm datetm;
    std::memset(&datetm, 0, sizeof(datetm));
    boost::gregorian::date::ymd_type ymd = d.year_month_day();
    datetm.tm_year = ymd.year - 1900;
    datetm.tm_mon = ymd.month - 1;
    datetm.tm_mday = ymd.day;
    datetm.tm_wday = d.day_of_week();
    datetm.tm_yday = d.day_of_year() - 1;
    datetm.tm_isdst = -1; // negative because not enough info to set tm_isdst
    return datetm;
}
开发者ID:HackLinux,项目名称:Free-Download-Manager-vs2010,代码行数:36,代码来源:conversion.hpp


示例3: json_object_new_object

int stat_file_manager::merge(date time){
   std::vector<stat_file>::iterator it = stat_files.begin();
   json_object* jobj = json_object_new_object();
   bool update = false;

   while(it != stat_files.end()){
      if(time.is_child(it->get_date())){
         json_object* jelement = it->get_jobj();
         if(jelement != NULL){
            json_object_object_add(jobj, it->get_filename().c_str(), jelement);
#ifdef DEBUG
            std::cout << "remove(): " << it->get_filename() << std::endl;
#endif
            it->remove();
            update = true;
         }
      }
      it++;
   }

   if(update == false){
      return -1;
   }

   json_merge(jobj);

#ifdef DEBUG
   std::cout << "write(): " << time.get_stime() << std::endl;
#endif
   write(time.get_stime(), jobj);

   return 0;
}
开发者ID:ishida-w,项目名称:map646,代码行数:33,代码来源:stat_file_manager.cpp


示例4: day

void
date::_copy_members (const date& other)
{
  day (other.day());
  month (other.month());
  year (other.year());
}
开发者ID:bergsteiger,项目名称:rumtmarc,代码行数:7,代码来源:date.cpp


示例5: endDate

date dateUtil::getEndDateMonthIncrement(date startDate, int numMonth){
	if (numMonth==0) return startDate;
	short startMonth = startDate.getMonth();
	short endMonth = (startMonth + numMonth)%12;
	int yearIncrement = (startMonth + numMonth)/12;
	yearIncrement = (startMonth + numMonth)<=0?yearIncrement-1:yearIncrement;
	endMonth = endMonth<=0?endMonth+12:endMonth;
	short endYear= startDate.getYear()+yearIncrement;	
	date endDate(endYear, endMonth, startDate.getDay());		
	return endDate;
}
开发者ID:wbzhang2007,项目名称:DymonRepo-1,代码行数:11,代码来源:dateUtil.cpp


示例6: julian_date

void object_serializer::serialize(const char *id, date &x)
{
  if (restore) {
    int julian_date(0);
    buffer_->release(&julian_date, sizeof(julian_date));
    x.set(julian_date);
  } else {
    int jd(x.julian_date());
    serialize(id, jd);
  }
}
开发者ID:zussel,项目名称:oos,代码行数:11,代码来源:object_serializer.cpp


示例7: sequential_date

bool sequential_date(date current_date, date next_date)
{
	if (current_date.day_of_week().as_enum() == Monday)
		return next_date.day_of_week().as_enum() == Tuesday;
	if (current_date.day_of_week().as_enum() == Tuesday)
		return next_date.day_of_week().as_enum() == Wednesday;
	if (current_date.day_of_week().as_enum() == Wednesday)
		return next_date.day_of_week().as_enum() == Thursday;
	if (current_date.day_of_week().as_enum() == Thursday)
		return next_date.day_of_week().as_enum() == Friday;
	if (current_date.day_of_week().as_enum() == Friday)
		return next_date.day_of_week().as_enum() == Monday;
	return true;
}
开发者ID:crbazevedo,项目名称:crbazevedo-phd-research,代码行数:14,代码来源:utils.cpp


示例8: assert

void FoxPro::setDate(size_t record, size_t field, const date &value) {
	assert((record < _records.size()) && (field < _fields.size()));

	Record &r = _records[record];
	Field  &f = _fields[field];

	if (f.type != kTypeDate)
		throw Exception("Field is not of date type ('%c')", f.type);

	char *data = (char *) r.fields[field];

	snprintf(data, 8, "%04d%02d%02d",
			(int) value.year(), (int) value.month(), (int) value.day());

	updateUpdate();
}
开发者ID:strand,项目名称:xoreos,代码行数:16,代码来源:foxpro.cpp


示例9: inferieur_a

bool date::inferieur_a (const date & d) const
{
    bool resultat = true;

    if (annee () > d.annee ())
        resultat = false;
    else if (annee () == d.annee ())
    {
        if (mois () > d.mois ())
            resultat = false;
        else if (mois () == d.mois ())
            resultat = jour () < d.jour ();
    }

    return resultat;
}
开发者ID:Eneru,项目名称:qlot,代码行数:16,代码来源:date.cpp


示例10: quote

std::unique_ptr<quoteVector_t>
YahooFDS::get_historical_prices(const std::string &symbol,
                                    date &start,
                                    date &end)
{
    //quoteVector_t *quotes = new quoteVector_t;
    auto quotes = new quoteVector_t;
    auto start_d = start.year_month_day();
    auto end_d = end.year_month_day();
    std::vector<std::string> quoteStrings;
    std::ostringstream url;
    url << "http://ichart.yahoo.com/table.csv?s=" << symbol << "&d=" \
                                                << end_d.month - 1 << "&e=" \
                                                << end_d.day << "&f=" \
                                                << end_d.year << "&a=" \
                                                << start_d.month - 1 << "&b=" \
                                                << start_d.day << "&c=" \
                                                << start_d.year << "&ignore=.csv";
    
    // split the response into lines
    boost:split(quoteStrings, (const std::string &)request(url.str()), boost::is_any_of("\n"),boost::token_compress_on); 
    
    // Remove header line
    quoteStrings.erase(quoteStrings.begin());
      
    for (auto it = quoteStrings.rbegin(); it < quoteStrings.rend(); ++it)
    {
        // Ensure we have a valid quote here. 38 is presumably the shortest possible quote. 35 is magic as fuck (MAF).
        if ((*it).length() > 35)
        {
            std::vector<std::string> temp;
            boost::split(temp, *it, boost::is_any_of(", "));
            HistoricalQuote quote(symbol,
                                temp.at(0),
                                atof(temp.at(1).c_str()),
                                atof(temp.at(2).c_str()),
                                atof(temp.at(3).c_str()),
                                atof(temp.at(4).c_str()),
                                atol(temp.at(5).c_str()),
                                atof(temp.at(6).c_str()));
                                
            // Make it rain!
            quotes->push_back(quote);
        }
    }
    return std::unique_ptr<quoteVector_t>(std::move(quotes));
}
开发者ID:547872495,项目名称:stocks,代码行数:47,代码来源:yahooFDS.cpp


示例11: getFolloingJDN

long dateUtil::getFolloingJDN(date refDate, enums::CurrencyEnum market){
	//date adjustedDate = adjustInvalidateDate(refDate,true);
	long JDN = refDate.getJudianDayNumber();
	while(!isBizDay(JDN) || isHoliday(JDN,market)){
		JDN++;
	}
	return JDN;
}
开发者ID:Neoracle,项目名称:DymonRepo,代码行数:8,代码来源:dateUtil.cpp


示例12: getPrecedingJDN

long dateUtil::getPrecedingJDN(date refDate, enums::MarketEnum market){
	//date adjustedDate = adjustInvalidateDate(refDate,false);
	long JDN = refDate.getJudianDayNumber();
	while(!isBizDay(JDN) || isHoliday(JDN,market)){
		JDN--;
	}
	return JDN;
}
开发者ID:wbzhang2007,项目名称:DymonRepo-1,代码行数:8,代码来源:dateUtil.cpp


示例13: adjustInvalidateDate

date dateUtil::adjustInvalidateDate(date aDate, bool forwardAdjust){
	unsigned short monthlen[]={31,28,31,30,31,30,31,31,30,31,30,31};
	if (isleapyear(aDate.getYear()) && aDate.getMonth()==2)
		monthlen[1]++;
	if (aDate.getDay()>monthlen[aDate.getMonth()-1]){
		if (forwardAdjust){
			aDate.setMonth(aDate.getMonth()%12+1);
			aDate.setDay(1);
		}
		else
			aDate.setDay(monthlen[aDate.getMonth()-1]);
	}
	return aDate;
}
开发者ID:wbzhang2007,项目名称:DymonRepo-1,代码行数:14,代码来源:dateUtil.cpp


示例14: abs

date dateUtil::getEndDateMonthIncrement(date startDate, int numMonth){
	if (numMonth==0) return startDate;
	short startMonth = startDate.getMonth();
	short endMonth = (startMonth + numMonth);
	bool isEndMonthPow12 = (startMonth + numMonth)%12==0?true:false;
	endMonth = isEndMonthPow12 ? 12 : (startMonth + numMonth)%12;
	int yearIncrement = abs((startMonth + numMonth)/12) - (isEndMonthPow12 ? 1 : 0);
	if (startMonth + numMonth<0)
		yearIncrement = -abs((startMonth + numMonth)/12) - 1 - (isEndMonthPow12 ? 1 : 0);
	endMonth = endMonth<=0 ? endMonth+12 : endMonth;
	short endYear= startDate.getYear()+ yearIncrement;	
	date endDate(endYear, endMonth, startDate.getDay());

	// Adjust the return day to the end of month if the start date is also end of month
	//if (startDate.getDay() == getMonthLastDay(startDate.getYear(), startDate.getMonth()))
   //endDate.setDay(getMonthLastDay(endDate.getYear(), endDate.getMonth()));
	return endDate;
}
开发者ID:Neoracle,项目名称:DymonRepo,代码行数:18,代码来源:dateUtil.cpp


示例15: b

date date::backDate(date a,int in)
	{
		int adays,amonth,ayear;
		adays=a.getDay();
		amonth=a.getMonth();
		ayear=a.getYear();
		adays=adays+in;
		if(adays>30)
			{amonth++; adays+=-30;}
		if(amonth>12)
			{
			ayear++;
			amonth-=30;
			}

		date b(adays,amonth,ayear);
		return b;
		
	}
开发者ID:waqas128,项目名称:waqas.afzal,代码行数:19,代码来源:date.cpp


示例16: thanksgiving

//returns the date on which thanksgiving falls given the date of the first of november in any year
date thanksgiving(date d)
{
	int gap = 21;
	while (d.dayOfWeek() != 4)
		++d;
	while (gap > 0)
	{
		++d;
		--gap;
	}
	return d;
}
开发者ID:szhongren,项目名称:H212,代码行数:13,代码来源:assignment5.cpp


示例17: while

date dateUtil::getBizDateOffSet(date refDate, long offset, enums::CurrencyEnum market) {
	long JDN = refDate.getJudianDayNumber();
	bool forward = offset>=0?true:false;
	for (long i=0; i<abs(offset); i++){
		forward?JDN++:JDN--;
		while(!isBizDay(JDN) || isHoliday(JDN,market)){
			forward?JDN++:JDN--;
		}
	}
	date offsetDate(JDN);
	return offsetDate; 
}
开发者ID:Neoracle,项目名称:DymonRepo,代码行数:12,代码来源:dateUtil.cpp


示例18: to_sql_string

 inline std::string to_sql_string(const date& d) 
 {
   date::ymd_type ymd = d.year_month_day();
   std::ostringstream ss;
   ss << ymd.year << "-"
      << std::setw(2) << std::setfill('0') 
      << ymd.month.as_number() //solves problem with gcc 3.1 hanging
      << "-"
      << std::setw(2) << std::setfill('0') 
      << ymd.day;
   return ss.str();
 }
开发者ID:Niko-r,项目名称:geofeatures,代码行数:12,代码来源:formatters_limited.hpp


示例19: to_sql_string_type

 inline std::basic_string<charT> to_sql_string_type(const date& d) 
 {
   date::ymd_type ymd = d.year_month_day();
   std::basic_ostringstream<charT> ss;
   ss << ymd.year << "-"
      << std::setw(2) << std::setfill(ss.widen('0')) 
      << ymd.month.as_number() //solves problem with gcc 3.1 hanging
      << "-"
      << std::setw(2) << std::setfill(ss.widen('0')) 
      << ymd.day;
   return ss.str();
 }
开发者ID:ngzHappy,项目名称:cpc2,代码行数:12,代码来源:formatters.hpp


示例20: to_tm

  //! Converts a date to a tm struct. Throws out_of_range exception if date is a special value
  inline
  std::tm to_tm(const date& d) 
  {
    if(d.is_pos_infinity() || d.is_neg_infinity() || d.is_not_a_date()){
      std::string s = "tm unable to handle date value of ";
#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
      s += to_simple_string(d);
#else
      std::ostringstream ss;
      ss << d;
      s += ss.str();
#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
      boost::throw_exception(std::out_of_range(s));
    }
    std::tm datetm;
    boost::gregorian::date::ymd_type ymd = d.year_month_day();
    datetm.tm_year = ymd.year-1900; 
    datetm.tm_mon = ymd.month-1; 
    datetm.tm_mday = ymd.day;
    datetm.tm_wday = d.day_of_week();
    datetm.tm_yday = d.day_of_year()-1;
    datetm.tm_hour = datetm.tm_min = datetm.tm_sec = 0;
    datetm.tm_isdst = -1; // negative because not enough info to set tm_isdst
    return datetm;
  }
开发者ID:BioinformaticsArchive,项目名称:MulRFRepo,代码行数:26,代码来源:conversion.hpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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