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


C++ CDate::getYear方法代码示例

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


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

示例1: getSameWeekDayOneYearLater

CDate CSeasonGenerator::getSameWeekDayOneYearLater(const CDate &date)
{
	// To match the same week day one year later
	// is necesary to look for leap years

	CDate newDate = date;
	newDate.setYear(newDate.getYear()+1);

	if( CDate::isLeap(date.getYear()) ){
		CDate Feb29(29, 02, date.getYear(), 23, 59, 59);
		if( date<=Feb29 ){
			newDate.setDay(newDate.getDay()-2);
		}
		else{
			newDate.setDay(newDate.getDay()-1);
		}
	}
	else{
		if( CDate::isLeap(date.getYear()+1) ){
			CDate Feb29(29, 02, date.getYear()+1, 23, 59, 59);
			if( newDate>Feb29 ){
				newDate.setDay(newDate.getDay()-2);
			}
			else{
				newDate.setDay(newDate.getDay()-1);
			}
		}
		else{
			newDate.setDay(newDate.getDay()-1);
		}
	}

	return newDate;
}
开发者ID:dividio,项目名称:projectfootball,代码行数:34,代码来源:CSeasonGenerator.cpp

示例2: enter

void CTeamPlayerDetailsWindowHandler::enter()
{
    IDAOFactory *daoFactory = m_game.getIDAOFactory();
    m_selectedTeamPlayer = m_game.getSelectedTeamPlayer();

    m_photo    ->setProperty("Image", "set:"+ m_selectedTeamPlayer->getSPhoto() +" image:"+m_selectedTeamPlayer->getSPhoto()+"_b");
    m_name     ->setText((CEGUI::utf8*)m_selectedTeamPlayer->getSName().c_str());
    m_shortName->setText((CEGUI::utf8*)m_selectedTeamPlayer->getSShortName().c_str());


    m_weight   ->setText((CEGUI::utf8*)m_selectedTeamPlayer->getNWeight_str().c_str());
    m_height   ->setText((CEGUI::utf8*)m_selectedTeamPlayer->getNHeight_str().c_str());

    CDate birthday = m_selectedTeamPlayer->getDBirthday();
    CDate today = CGameEngine::getInstance()->getTimeManager()->getCurrentTime();
    int years = today.getYear() - birthday.getYear();
    if((today.getMonth() < birthday.getMonth()) ||
       (today.getMonth() == birthday.getMonth() && today.getDay() < birthday.getDay())) {
        years = years - 1;
    }
    std::ostringstream yearsAux;
    yearsAux << years;
    m_birthday ->setText(birthday.format("%d/%m/%Y"));
    m_years    ->setText((CEGUI::utf8*)yearsAux.str().c_str());

    CPfCountries *country = daoFactory->getIPfCountriesDAO()->findByXCountry(m_selectedTeamPlayer->getXFkCountry());
    m_country     ->setText((CEGUI::utf8*)gettext(country->getSShortName().c_str()));
    m_country_flag->setProperty("Image", "set:"+ country->getSFlag() +" image:"+country->getSFlag()+"_flag");
    delete country;

    std::string            currentTimestamp  = m_game.getCurrentTime().getTimestamp();
    CPfTeamPlayerContracts *contract = daoFactory->getIPfTeamPlayerContractsDAO()->findActiveByXFkTeamPlayer(m_selectedTeamPlayer->getXTeamPlayer_str(), currentTimestamp);
    CPfTeams               *team     = daoFactory->getIPfTeamsDAO()->findByXTeam(contract->getXFkTeam_str());
    m_teamName     ->setText((CEGUI::utf8*)team->getSTeam().c_str());
    m_dateBegin    ->setText(contract->getDBegin().format("%d/%m/%Y"));
    m_dateEnd      ->setText(contract->getDEnd().format("%d/%m/%Y"));
    m_salary       ->setText((CEGUI::utf8*)contract->getNSalary_str().c_str());
    m_releaseClause->setText((CEGUI::utf8*)contract->getNReleaseClause_str().c_str());
    delete team;
    delete contract;
}
开发者ID:dividio,项目名称:projectfootball,代码行数:41,代码来源:CTeamPlayerDetailsWindowHandler.cpp


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