예제 #1
0
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;
}
예제 #2
0
      int CCalendar::getNbSecond(const CDate & date) const
      { // Retourne le nombre de secondes écoulées depuis le début de l'année.
         CDate _d0(date); int  nbday = 0;

         for(_d0.setMonth(1); _d0.getMonth() < date.getMonth(); _d0.setMonth(_d0.getMonth()+1))
            nbday += getMonthLength(_d0);
         return ((((nbday + date.getDay()) * getDayLength() + date.getHour()) * getHourLength()
                     + date.getMinute()) * getMinuteLength() + date.getSecond());
      }
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;
}
예제 #4
0
void CTimeManager::endDayEventHandler(const IGameEvent &event)
{
	// Only one "NoMoreEventsToday" event is on the events queue at time,
	// so we need to add a new event of this type for tomorrow

	CDate date = event.getDate();
	date.setDay(date.getDay()+1);
	date.setHour(23);
	date.setMin(59);
	date.setSec(59);
	CGameEngine::getInstance()->getEventManager()->addEvent(new CEndDayEvent(date));
}