您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ Date函数代码示例

51自学网 2021-06-01 20:25:22
  C++
这篇教程C++ Date函数代码示例写得很实用,希望能帮到您。

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

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

示例1: Date

Date Date::Minutes(int n) {  return Date(n * gsSecsPerMinute, true);}
开发者ID:gatgui,项目名称:gcore,代码行数:3,


示例2: Date

Date Date::startOfYear () const{  return Date (1, 1, year (), 0, 0, 0);}
开发者ID:SEJeff,项目名称:task,代码行数:4,


示例3: keyf

void MyDayInfoPlot::DrawPricePlot(wxDC&dc){    TotalDayInfoStru MyDays[TOTAY_DAYS_MYDAYINFO];    double MaxSz,MinSz,MaxSh,MinSh,MaxTotal,MinTotal,MaxDelta,MinDelta;	MaxSz=MinSz=MaxSh=MinSh=MaxTotal=MinTotal=MaxDelta=MinDelta=0;	for (int tidx=0;tidx<TOTAY_DAYS_MYDAYINFO;tidx++){		MyDays[tidx].Valid=false;	}    wxString keyPath=WStockConfig::GetMyDayInfoPath();    wxFileName keyf(keyPath);    keyf.MakeAbsolute();    xmlDocPtr doc=NULL;    if (keyf.FileExists()){        //Load Stocks Name From file		doc = xmlParseFile((const char*)keyf.GetFullPath().mb_str());    }    //If Load Fail, Create the Xml Memory    if (doc==NULL){        dc.DrawText(_("No Info File Found!"),10,10);        return;    }    for (xmlNodePtr node=doc->children->children;node;node=node->next){            if (xmlStrcmp(node->name,(const xmlChar*)"DayInfo")==0){				wxString Date(wxConvUTF8.cMB2WC(					(char*)xmlGetProp(node, (const xmlChar*)"Date")),*wxConvCurrent);				wxString Sz(wxConvUTF8.cMB2WC(					(char*)xmlGetProp(node, (const xmlChar*)"ShenZhen")),*wxConvCurrent);				wxString Sh(wxConvUTF8.cMB2WC(					(char*)xmlGetProp(node, (const xmlChar*)"ShangHai")),*wxConvCurrent);				wxString Total(wxConvUTF8.cMB2WC(					(char*)xmlGetProp(node, (const xmlChar*)"Total")),*wxConvCurrent);				wxString Delta(wxConvUTF8.cMB2WC(					(char*)xmlGetProp(node, (const xmlChar*)"TodayEarning")),*wxConvCurrent);                wxDateTime date;                date.ParseDate(Date);                int idx=(wxDateTime::Today()-date).GetDays();                if  (idx<TOTAY_DAYS_MYDAYINFO){                    Sz.ToDouble(&MyDays[idx].sz);                    Sh.ToDouble(&MyDays[idx].sh);                    Total.ToDouble(&MyDays[idx].total);                    Delta.ToDouble(&MyDays[idx].delta);					MyDays[idx].Valid = true;					MyDays[idx].date = date;                }            }    }	int i;	for (i=0;i<TOTAY_DAYS_MYDAYINFO;i++){		if (MyDays[i].Valid){			if (MyDays[i].sz>MaxSz) MaxSz = MyDays[i].sz;			if (MyDays[i].sz<MinSz) MinSz = MyDays[i].sz;			if (MyDays[i].sh>MaxSh) MaxSh = MyDays[i].sh;			if (MyDays[i].sh<MinSh) MinSh = MyDays[i].sh;			if (MyDays[i].total>MaxTotal) MaxTotal = MyDays[i].total;			if (MyDays[i].total<MinTotal) MinTotal = MyDays[i].total;			if (MyDays[i].delta>MaxDelta) MaxDelta = MyDays[i].delta;			if (MyDays[i].delta<MinDelta) MinDelta = MyDays[i].delta;		}	}	dc.SetPen(wxPen(*wxBLACK,3));	int XStart=100,YStart=10,YFree=60;	int TotalY=dc.GetSize().y-30-YFree;	int XTotal = dc.GetSize().x-110;	float TotalDelta=0;	if (MinDelta<0)	TotalDelta = MaxTotal - MinDelta+YFree;	else TotalDelta = MaxTotal+YFree;	if (TotalDelta<0.0003) TotalDelta = 1;	int ZeroY = (int)(double)(TotalY/TotalDelta * MaxTotal + YStart);	dc.DrawLine(XStart,YStart,XStart,YStart + TotalY + YFree);	dc.DrawLine(XStart-10,ZeroY,XStart+XTotal,ZeroY);	for (i=0;i<TOTAY_DAYS_MYDAYINFO;i++){		if (MyDays[i].Valid){			int MyTotalY=(int)(double)(ZeroY - TotalY/TotalDelta * MyDays[i].total);			int MyDeltaY=(int)(double)(ZeroY - TotalY/TotalDelta * MyDays[i].delta);			dc.SetBrush(*wxBLACK_BRUSH);			dc.DrawRectangle(XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1)) - 5,MyTotalY,10,Abs(ZeroY-MyTotalY));			dc.SetBrush(*wxGREEN_BRUSH);			dc.DrawRectangle(XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1)) - 5,MyDeltaY,10,Abs(ZeroY-MyDeltaY));			//wxLogMessage(wxT("Draw Rect at:%d %d %d %d"),(int)(XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1)) - 5),			//MyDeltaY,10,Abs(ZeroY-MyDeltaY));			dc.DrawText(MyDays[i].date.FormatISODate(),XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1))-30,YStart+TotalY);		}	}}
开发者ID:Sunwinds,项目名称:wesleystock,代码行数:96,


示例4: sow

Date Date::startOfWeek () const{  Date sow (_t);  sow -= (dayOfWeek () * 86400);  return Date (sow.month (), sow.day (), sow.year (), 0, 0, 0);}
开发者ID:SEJeff,项目名称:task,代码行数:6,


示例5: Date

 MakeOIS& MakeOIS::withSettlementDays(Natural settlementDays) {     settlementDays_ = settlementDays;     effectiveDate_ = Date();     return *this; }
开发者ID:21hub,项目名称:QuantLib,代码行数:5,


示例6: Date

    Time ActualActual::ISMA_Impl::yearFraction(const Date& d1,                                               const Date& d2,                                               const Date& d3,                                               const Date& d4) const {        if (d1 == d2)            return 0.0;        if (d1 > d2)            return -yearFraction(d2,d1,d3,d4);        // when the reference period is not specified, try taking        // it equal to (d1,d2)        Date refPeriodStart = (d3 != Date() ? d3 : d1);        Date refPeriodEnd = (d4 != Date() ? d4 : d2);        QL_REQUIRE(refPeriodEnd > refPeriodStart && refPeriodEnd > d1,                   "invalid reference period: "                   << "date 1: " << d1                   << ", date 2: " << d2                   << ", reference period start: " << refPeriodStart                   << ", reference period end: " << refPeriodEnd);        // estimate roughly the length in months of a period        Integer months =            Integer(0.5+12*Real(refPeriodEnd-refPeriodStart)/365);        // for short periods...        if (months == 0) {            // ...take the reference period as 1 year from d1            refPeriodStart = d1;            refPeriodEnd = d1 + 1*Years;            months = 12;        }        Time period = Real(months)/12.0;        if (d2 <= refPeriodEnd) {            // here refPeriodEnd is a future (notional?) payment date            if (d1 >= refPeriodStart) {                // here refPeriodStart is the last (maybe notional)                // payment date.                // refPeriodStart <= d1 <= d2 <= refPeriodEnd                // [maybe the equality should be enforced, since                // refPeriodStart < d1 <= d2 < refPeriodEnd                // could give wrong results] ???                return period*Real(dayCount(d1,d2)) /                    dayCount(refPeriodStart,refPeriodEnd);            } else {                // here refPeriodStart is the next (maybe notional)                // payment date and refPeriodEnd is the second next                // (maybe notional) payment date.                // d1 < refPeriodStart < refPeriodEnd                // AND d2 <= refPeriodEnd                // this case is long first coupon                // the last notional payment date                Date previousRef = refPeriodStart - months*Months;                if (d2 > refPeriodStart)                    return yearFraction(d1, refPeriodStart, previousRef,                                        refPeriodStart) +                        yearFraction(refPeriodStart, d2, refPeriodStart,                                     refPeriodEnd);                else                    return yearFraction(d1,d2,previousRef,refPeriodStart);            }        } else {            // here refPeriodEnd is the last (notional?) payment date            // d1 < refPeriodEnd < d2 AND refPeriodStart < refPeriodEnd            QL_REQUIRE(refPeriodStart<=d1,                       "invalid dates: "                       "d1 < refPeriodStart < refPeriodEnd < d2");            // now it is: refPeriodStart <= d1 < refPeriodEnd < d2            // the part from d1 to refPeriodEnd            Time sum = yearFraction(d1, refPeriodEnd,                                    refPeriodStart, refPeriodEnd);            // the part from refPeriodEnd to d2            // count how many regular periods are in [refPeriodEnd, d2],            // then add the remaining time            Integer i=0;            Date newRefStart, newRefEnd;            for (;;) {                newRefStart = refPeriodEnd + (months*i)*Months;                newRefEnd = refPeriodEnd + (months*(i+1))*Months;                if (d2 < newRefEnd) {                    break;                } else {                    sum += period;                    i++;                }            }            sum += yearFraction(newRefStart,d2,newRefStart,newRefEnd);            return sum;        }    }
开发者ID:AAthresh,项目名称:quantlib,代码行数:96,


示例7: Date

void FenetreProgrammerActivite::enregistrer(){    programmation& progact = agenda::getInstance().ajouterProgrammationActivite(activite, Date(ProgDate->date().day(),ProgDate->date().month(),ProgDate->date().year()),Horaire(ProgHh->value(), ProgHm->value()));    if(&progact!=0){        QMessageBox msgBox;        msgBox.setText("L'Activité a été programmée");        msgBox.exec();        this->close();    }    else    {        delete &progact;        QMessageBox msgBox;        msgBox.setText("L'Activité n'a pas été programmée");        msgBox.exec();    }}
开发者ID:clemencevaz,项目名称:LO21,代码行数:16,


示例8: main

int main(){	try	{		odb::session s; // this keeps shared pointers consistent after reloading them from the db (turns on object cache)		std::unique_ptr<odb::database> db( new Database( "Branch_removeEmployee.test.db", true ) );		// a set storing all employees we want to add		std::unordered_set< std::shared_ptr<Employee> > employees;		employees.insert( std::shared_ptr<Employee>( new Employee( "A", Date(1,1,1967) ) ) );		employees.insert( std::shared_ptr<Employee>( new Employee( "B", Date(2,1,1968) ) ) );		employees.insert( std::shared_ptr<Employee>( new Employee( "C", Date(3,1,1969) ) ) );		// we will add all employees to one branch		std::shared_ptr<Branch> b( new Branch( "Main", Address() ) );		for( const std::shared_ptr<Employee> & e : employees )			assert( b->addEmployee( e ) );		// for accessing the stored branch by id		std::string branch_id;		// store branch and employees		{			odb::transaction t( db->begin() );			for( const std::shared_ptr<Employee> & e : employees )			{				db->persist( e );				std::cout << "Stored " << e->getName() << "/n";			}			branch_id = db->persist( b );			t.commit();		}		// remove an employee from the stored branch one after the other		for( auto i = employees.begin(); i != employees.end(); )		{			// retrieve the stored branch and remove an employee			{				odb::transaction t( db->begin() );				std::shared_ptr<Branch> b( db->load<Branch>( branch_id ) );				for( const odb::lazy_weak_ptr<Employee> & le : b->getEmployees() )				{					std::cout << "Still persistent: " << le.object_id() << "/n";				}				assert( (*i)->getBranch() == b ); // should be connected to branch				// remove employee				assert( b->removeEmployee( (*i) ) );				assert( b->getEmployees().size() == employees.size()-1 ); // should be removed locally				assert( (*i)->getBranch() == nullptr ); // should not be connected to any branch anymore				// remove second time (should fail)				assert( !b->removeEmployee( (*i) ) ); // should not be able to remove twice				assert( b->getEmployees().size() == employees.size()-1 ); // should stay the same				assert( (*i)->getBranch() == nullptr ); // should still not be connected to any branch				db->update( b );				t.commit();			}			// reload person from database and check if employee got removed			{				odb::transaction t( db->begin() );				std::shared_ptr<Branch> b( db->load<Branch>( branch_id ) );				assert( b->getEmployees().size() == employees.size()-1 ); // should be removed in database too				t.commit();			}			std::cout << "Deleting: " << (*i) << " - " << (*i)->getName()  << "/n";			i = employees.erase( i );		}	}	catch( const odb::exception & e )	{		std::cerr << "Exception: " << e.what() << std::endl;		std::exit( EXIT_FAILURE );	}	return 0;}
开发者ID:zwostein,项目名称:odb-playground,代码行数:78,


示例9: Date

bool CDate::EncodeDate(    const CString& DateString,     const CString& DateFormat,     struct tm& Result) {  CString Date(DateString);    static const char * Months[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};  static const char * WeekDays[] = {"Sun", "Mon","Tue","Wed","Thu","Fri","Sat"};  static const char * Zones[] = {"UTC", "GMT", "EDT", "EST", "CDT", "CST", "MDT", "MST", "PDT", "PST"};  static const int ZonesHoursSkew[] = {0, 0, 4, 5, 5, 6, 6, 7, 7, 8};	  CString WeekDay;  CString Month;  CString Zone;    Date.Replace('-', ' ');  memset(&Result, 0, sizeof(Result));  bool fScan =       SSScan(          Date,           &DateFormat,           &WeekDay,           NULL,           &Result.tm_mday,           &Month,           &Result.tm_year,           &Result.tm_hour,           NULL,           &Result.tm_min,           NULL,           &Result.tm_sec,           &Zone);    Trace(tagDateTime, levVerbose,         ("CDate:: EncodeDate - scanned %s with " /         "WeekDay: %s " /         "Day: %d " /         "Month: %s " /         "Year: %d " /         "Hour: %d " /         "Minute: %d " /         "Second: %d " /         "Zone: %s",          Date.GetBuffer(),         WeekDay.GetBuffer(),         Result.tm_mday,         Month.GetBuffer(),         Result.tm_year,         Result.tm_hour,         Result.tm_min,         Result.tm_sec,         Zone.GetBuffer()));    if (fScan) {		int i;      		if (Result.tm_year > 1900) 			Result.tm_year-=1900;    		for (i = 0; i < BASE_DIM(Months); i++) {			if (Month.Same(Months[i])) {				Result.tm_mon = i;				break;			}		}		for (i = 0; i < BASE_DIM(WeekDays); i++) {			// support full weekdays as well			if (WeekDay.StartsWithSame(WeekDays[i])) {				Result.tm_wday = i;				break;			}		}		// time zone adjustments		int ZoneAdjustment = 0;		if (Zone.IsInt( & ZoneAdjustment)) {			ZoneAdjustment *= 3600;		} else {			for (i = 0; i < BASE_DIM(Zones); i++) {				if (Zone.Same(Zones[i])) {					ZoneAdjustment = ZonesHoursSkew[i] * 3600;					break;				}			}		}		Trace(tagDateTime, levVerbose, ("CDate:: EncodeSimpleDate - ZoneAdjustment %d second(s)", ZoneAdjustment));		Result.tm_isdst = 0;		if (ZoneAdjustment) {			time_t AdjustedTime;#ifdef _UNIX			base_gmtime(AdjustedTime, Result);//.........这里部分代码省略.........
开发者ID:dblock,项目名称:baseclasses,代码行数:101,


示例10: SmileSection

NoArbSabrSmileSection::NoArbSabrSmileSection(    const Date &d, Rate forward, const std::vector<Real> &sabrParams,    const DayCounter &dc, Real shift)    : SmileSection(d, dc, Date()), forward_(forward), params_(sabrParams), shift_(shift) {    init();}
开发者ID:21hub,项目名称:QuantLib,代码行数:6,


示例11: Date

Date Grader07::getDueDate(){  return Date(12, 5, 2013);}
开发者ID:suryak,项目名称:Advanced-Data-Structures,代码行数:4,


示例12: m_startDate

 /// constructor with year Calendar::Calendar(int year)   : m_startDate(Date(MonthOfYear::Jan, 1, year)), m_endDate(Date(MonthOfYear::Dec, 31, year)) {}
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:4,


示例13: year

voidMonthDayRuleTest::test_utilities(){	int yearIndex;	SetDate date;	Year year ( DateUtil::year());	Date newYearDate (year, Month(1), DayOfMonth(1));	Date july4Date (year, Month(7), DayOfMonth(4));	Date christmasDate(year, Month(12), DayOfMonth(25));	//test: MontDayRule::virtual Date calcDate(const Year& year) const ;	MonthDayRule newYearRule ("Rule", Month(1), DayOfMonth(1));	date = newYearRule.calcDate(year);	CPPUNIT_ASSERT(newYearDate == *date.begin());	for (yearIndex = year.getValue(); yearIndex <= year.getValue() + 50; ++yearIndex){		date = newYearRule.calcDate(Year(yearIndex));		CPPUNIT_ASSERT(newYearDate == *date.begin());		newYearDate.addYear(1);	}		MonthDayRule july4Rule ("July4Rule", Month(7), DayOfMonth(4));	date = july4Rule.calcDate(year);	CPPUNIT_ASSERT(july4Date == *date.begin());	MonthDayRule christmasRule("ChristmasRule", Month(12), DayOfMonth(25));	date = christmasRule.calcDate(year);	CPPUNIT_ASSERT(christmasDate == *date.begin());	//Test for weekendAdjustment	WeekendRuleSharedPtr weekendRulePtr(new WeekendRule("WeekendRule"));	weekendRulePtr->addDay(WeekDay::Saturday);	weekendRulePtr->addDay(WeekDay::Sunday);	MonthDayRule adjustingNewYearRule ("AdjustingNewYear", Month(1), DayOfMonth(1));	adjustingNewYearRule.setStartEffectiveDate(20110101);	adjustingNewYearRule.setWeekendAdjustment(WeekendAdjustment::ClosestWeekDay);	adjustingNewYearRule.setWeekendRule(weekendRulePtr);	//First check for Saturday -> prior Friday	date = adjustingNewYearRule.calcDate(Year(2011));	CPPUNIT_ASSERT(Date(20101231) == *date.begin());	//First check for Sunday -> next Monday	date = adjustingNewYearRule.calcDate(Year(2012));	CPPUNIT_ASSERT(Date(20120102) == *date.begin());	//Check for no adjustment is required	date = adjustingNewYearRule.calcDate(Year(2013));	CPPUNIT_ASSERT(Date(20130101) == *date.begin());	//Rule is disabled	try{		newYearRule.setEnabledFlag(false);		newYearRule.calcDate(year);	}	catch (BaseException& ex){		CAUGHT_EXCEPTION(ex,"Calculation called on disabled rule");	}	newYearRule.setEnabledFlag(true);	 	//Rule start date year > calc year	try{		newYearRule.calcDate(Year(2010));	}	catch (BaseException& ex){		CAUGHT_EXCEPTION(ex,"Calculation called for year before  rule is in effect");	}	//Rule calc year >  rule end date year	try{		newYearRule.setEndEffectiveDate(20121231);		newYearRule.calcDate(Year(2030));	}	catch (BaseException& ex){		CAUGHT_EXCEPTION(ex,"Calculation called for year after  rule is in effect");	}}
开发者ID:ajaniv,项目名称:softwarebook,代码行数:81,


示例14: Copy

void CValue::SetDate(CString s){	Copy(Date(s));}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:4,


示例15: cmsSchedule

    MakeCms::operator boost::shared_ptr<Swap>() const {        Date startDate;        if (effectiveDate_ != Date())            startDate = effectiveDate_;        else {            Natural fixingDays = iborIndex_->fixingDays();            Date referenceDate = Settings::instance().evaluationDate();            Date spotDate = floatCalendar_.advance(referenceDate,                                                   fixingDays*Days);            startDate = spotDate+forwardStart_;        }        Date terminationDate = startDate+swapTenor_;        Schedule cmsSchedule(startDate, terminationDate,                             cmsTenor_, cmsCalendar_,                             cmsConvention_,                             cmsTerminationDateConvention_,                             cmsRule_, cmsEndOfMonth_,                             cmsFirstDate_, cmsNextToLastDate_);        Schedule floatSchedule(startDate, terminationDate,                               floatTenor_, floatCalendar_,                               floatConvention_,                               floatTerminationDateConvention_,                               floatRule_ , floatEndOfMonth_,                               floatFirstDate_, floatNextToLastDate_);        Leg cmsLeg = CmsLeg(cmsSchedule, swapIndex_)            .withNotionals(nominal_)            .withPaymentDayCounter(cmsDayCount_)            .withPaymentAdjustment(cmsConvention_)            .withFixingDays(swapIndex_->fixingDays())            .withGearings(cmsGearing_)            .withSpreads(cmsSpread_)            .withCaps(cmsCap_)            .withFloors(cmsFloor_);        if (couponPricer_)            setCouponPricer(cmsLeg, couponPricer_);        Rate usedSpread = iborSpread_;        if (useAtmSpread_) {            QL_REQUIRE(!iborIndex_->forwardingTermStructure().empty(),                       "null term structure set to this instance of " <<                       iborIndex_->name());            QL_REQUIRE(!swapIndex_->forwardingTermStructure().empty(),                       "null term structure set to this instance of " <<                       swapIndex_->name());            QL_REQUIRE(couponPricer_,                       "no CmsCouponPricer set (yet)");            Leg floatLeg = IborLeg(floatSchedule, iborIndex_)                .withNotionals(nominal_)                .withPaymentDayCounter(floatDayCount_)                .withPaymentAdjustment(floatConvention_)                .withFixingDays(iborIndex_->fixingDays());            Swap temp(cmsLeg, floatLeg);            temp.setPricingEngine(engine_);            Real npv = temp.legNPV(0)+temp.legNPV(1);            usedSpread = -npv/temp.legBPS(1)*1e-4;        } else {            QL_REQUIRE(usedSpread != Null<Spread>(),                       "null spread set");        }        Leg floatLeg = IborLeg(floatSchedule, iborIndex_)            .withNotionals(nominal_)            .withPaymentDayCounter(floatDayCount_)            .withPaymentAdjustment(floatConvention_)            .withFixingDays(iborIndex_->fixingDays())            .withSpreads(usedSpread);        boost::shared_ptr<Swap> swap;        if (payCms_)            swap = boost::shared_ptr<Swap>(new Swap(cmsLeg, floatLeg));        else            swap = boost::shared_ptr<Swap>(new Swap(floatLeg, cmsLeg));        swap->setPricingEngine(engine_);        return swap;    }
开发者ID:AlexJiaeHwang,项目名称:quantlib,代码行数:83,


示例16: schedule

    MakeOIS::operator shared_ptr<OvernightIndexedSwap>() const {        Date startDate;        if (effectiveDate_ != Date())            startDate = effectiveDate_;        else {            Date refDate = Settings::instance().evaluationDate();            // if the evaluation date is not a business day            // then move to the next business day            refDate = calendar_.adjust(refDate);            Date spotDate = calendar_.advance(refDate,                                              settlementDays_*Days);            startDate = spotDate+forwardStart_;            if (forwardStart_.length()<0)                startDate = calendar_.adjust(startDate, Preceding);            else                startDate = calendar_.adjust(startDate, Following);        }        // OIS end of month default        bool usedEndOfMonth =             isDefaultEOM_ ? calendar_.isEndOfMonth(startDate) : endOfMonth_;        Date endDate = terminationDate_;        if (endDate == Date()) {            if (usedEndOfMonth)                endDate = calendar_.advance(startDate,                                            swapTenor_,                                            ModifiedFollowing,                                            usedEndOfMonth);            else                endDate = startDate + swapTenor_;        }        Schedule schedule(startDate, endDate,                          Period(paymentFrequency_),                          calendar_,                          ModifiedFollowing,                          ModifiedFollowing,                          rule_,                          usedEndOfMonth);        Rate usedFixedRate = fixedRate_;        if (fixedRate_ == Null<Rate>()) {            OvernightIndexedSwap temp(type_, nominal_,                                      schedule,                                      0.0, // fixed rate                                      fixedDayCount_,                                      overnightIndex_, overnightSpread_);            if (engine_ == 0) {                Handle<YieldTermStructure> disc =                                    overnightIndex_->forwardingTermStructure();                QL_REQUIRE(!disc.empty(),                           "null term structure set to this instance of " <<                           overnightIndex_->name());                bool includeSettlementDateFlows = false;                shared_ptr<PricingEngine> engine(new                    DiscountingSwapEngine(disc, includeSettlementDateFlows));                temp.setPricingEngine(engine);            } else                temp.setPricingEngine(engine_);            usedFixedRate = temp.fairRate();        }        shared_ptr<OvernightIndexedSwap> ois(new            OvernightIndexedSwap(type_, nominal_,                                 schedule,                                 usedFixedRate, fixedDayCount_,                                 overnightIndex_, overnightSpread_));        if (engine_ == 0) {            Handle<YieldTermStructure> disc =                                overnightIndex_->forwardingTermStructure();            bool includeSettlementDateFlows = false;            shared_ptr<PricingEngine> engine(new                DiscountingSwapEngine(disc, includeSettlementDateFlows));            ois->setPricingEngine(engine);        } else            ois->setPricingEngine(engine_);        return ois;    }
开发者ID:21hub,项目名称:QuantLib,代码行数:83,


示例17: containsARateSetOn

 bool MonthlyFixingCurve::containsARateSetOn(QuantLib::Date date) const {     return FixingRateSource::containsARateSetOn(Date(1, date.month(), date.year())); }
开发者ID:daveysj,项目名称:sjd,代码行数:4,


示例18: FormCreate

void __fastcall TRegPac::FormCreate(TObject *Sender){        fechNac->Date=Date()-366;        }
开发者ID:jsalvag,项目名称:ConsultorioOdontologico,代码行数:4,


示例19: getRateSetOn

 double MonthlyFixingCurve::getRateSetOn(QuantLib::Date date) const {     return FixingRateSource::getRateSetOn(Date(1, date.month(), date.year())); }
开发者ID:daveysj,项目名称:sjd,代码行数:4,


示例20: Date

    bool China::IbImpl::isBusinessDay(const Date& date) const {        static const Date working_weekends[] = {            // 2005            Date(5, February, 2005),            Date(6, February, 2005),            Date(30, April, 2005),            Date(8, May, 2005),            Date(8, October, 2005),            Date(9, October, 2005),            Date(31, December, 2005),            //2006            Date(28, January, 2006),            Date(29, April, 2006),            Date(30, April, 2006),            Date(30, September, 2006),            Date(30, December, 2006),            Date(31, December, 2006),            // 2007            Date(17, February, 2007),            Date(25, February, 2007),            Date(28, April, 2007),            Date(29, April, 2007),            Date(29, September, 2007),            Date(30, September, 2007),            Date(29, December, 2007),            // 2008            Date(2, February, 2008),            Date(3, February, 2008),            Date(4, May, 2008),            Date(27, September, 2008),            Date(28, September, 2008),            // 2009            Date(4, January, 2009),            Date(24, January, 2009),            Date(1, February, 2009),            Date(31, May, 2009),            Date(27, September, 2009),            Date(10, October, 2009),            // 2010            Date(20, February, 2010),            Date(21, February, 2010),            Date(12, June, 2010),            Date(13, June, 2010),            Date(19, September, 2010),            Date(25, September, 2010),            Date(26, September, 2010),            Date(9, October, 2010),            // 2011            Date(30, January, 2011),            Date(12, February, 2011),            Date(2, April, 2011),            Date(8, October, 2011),            Date(9, October, 2011),            Date(31, December, 2011),            // 2012            Date(21, January, 2012),            Date(29, January, 2012),            Date(31, March, 2012),            Date(1, April, 2012),            Date(28, April, 2012),            Date(29, September, 2012),            // 2013            Date(5,January,2013),            Date(6,January,2013),            Date(16,February,2013),            Date(17,February,2013),            Date(7,April,2013),            Date(27,April,2013),            Date(28,April,2013),            Date(8,June,2013),            Date(9,June,2013),            Date(22,September,2013),            Date(29,September,2013),            Date(12,October,2013),            // 2014            Date(26,January,2014),            Date(8,February,2014),            Date(4,May,2014),            Date(28,September,2014),            Date(11,October,2014),            // 2015            Date(4,January,2015),            Date(15,February,2015),            Date(28,February,2015),            Date(6,September,2015),            Date(10,October,2015),            // 2016            Date(6,February,2016),            Date(14,February,2016),            Date(12,June,2016),            Date(18,September,2016),            Date(8,October,2016),            Date(9,October,2016)        };        static const Size n =            sizeof(working_weekends)/sizeof(working_weekends[0]);        static const std::set<Date> workingWeekends(working_weekends+0,                                                    working_weekends+n);        // If it is already a SSE business day, it must be a IB business day//.........这里部分代码省略.........
开发者ID:grantathon,项目名称:nquantlib64,代码行数:101,


示例21: pathNpv

    CatBond::results MonteCarloCatBondEngine::npv(bool includeSettlementDateFlows, 												  Date settlementDate, 									              Date npvDate) const    {	    const size_t MAX_PATHS = 10000; //TODO		CatBond::results result;		result.reset();        double lossProbability =  0.0;        double exhaustionProbability = 0.0;        double expectedLoss = 0.0;		//GenericRiskStatistics<GeneralStatistics> statistics;		GeneralStatistics statistics;        if (arguments_.cashflows.empty()) {			 return result;		}        if (settlementDate == Date())            settlementDate = Settings::instance().evaluationDate();        if (npvDate == Date())            npvDate = settlementDate;        Real totalNPV = 0.0;        Date effectiveDate = std::max(arguments_.startDate, settlementDate);        Date maturityDate = (*arguments_.cashflows.rbegin())->date();        auto catSimulation = catRisk_->newSimulation(effectiveDate, maturityDate);        std::vector<std::pair<Date, Real> > eventsPath;        NotionalPath notionalPath;        Real riskFreeNPV = pathNpv(includeSettlementDateFlows, settlementDate, notionalPath);        size_t pathCount=0;        while(catSimulation->nextPath(eventsPath) && pathCount<MAX_PATHS)        {            arguments_.notionalRisk->updatePath(eventsPath, notionalPath);            if(notionalPath.loss()>0) { //optimization, most paths will not include any loss				double thisNpv = pathNpv(includeSettlementDateFlows, settlementDate, notionalPath);                totalNPV += thisNpv;                lossProbability+=1;                if (notionalPath.loss()==1)                     exhaustionProbability+=1;                expectedLoss+=notionalPath.loss();				statistics.add(thisNpv, 1.0);            } else {                totalNPV += riskFreeNPV;				statistics.add(riskFreeNPV, 1.0);            }            pathCount++;        }        lossProbability/=pathCount;        exhaustionProbability/=pathCount;        expectedLoss/=pathCount;		result.valuationDate = settlementDate;		result.value = totalNPV/(pathCount*discountCurve_->discount(npvDate));		result.settlementValue = result.value;		result.lossProbability = lossProbability;		result.exhaustionProbability = exhaustionProbability;		result.expectedLoss = expectedLoss;		if(Null<Real>()!=varLevel_) {			result.var = result.value - statistics.percentile(1.0-varLevel_);			result.stdDev = statistics.standardDeviation();			result.skew = statistics.skewness();			result.kurtosis = statistics.kurtosis();		}        return result;    }
开发者ID:gandrusz,项目名称:quantlib,代码行数:68,


示例22: createTMStruct

Date UTCStamp::getDate() const{	struct tm tStamp = createTMStruct();	return Date(tStamp.tm_mday, tStamp.tm_mon + 1, tStamp.tm_year + 1900);}
开发者ID:JohnDNoodle,项目名称:JDNRepo,代码行数:5,



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


C++ Datum函数代码示例
C++ Database_write函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。