Пример #1
0
int CTestDateApp::Run(void)
{
    const CArgs& args = GetArgs();
    CDate      date;
    CDate_std& std  = date.SetStd();
    std.SetYear(args["Y"].AsInteger());
    if (args["M"]) {
        std.SetMonth(args["M"].AsInteger());
    }
    if (args["D"]) {
        std.SetDay(args["D"].AsInteger());
    }
    if (args["S"]) {
        std.SetSeason(args["S"].AsString());
    }
    // ...

    string s;
    date.GetDate(&s);
    NcbiCout << '\"' << s << '\"' << NcbiEndl;
    s.erase();
    date.GetDate(&s, args["f"].AsString());
    NcbiCout << '\"' << s << '\"' << NcbiEndl;
    s.erase();
    date.GetDate(&s, "%Y-%M-%D");
    NcbiCout << '\"' << s << '\"' << NcbiEndl;

    return 0;
}
Пример #2
0
//----------------------------------------
std::string CUnit::GetDateRefAs1950() const
{

  std::string result;

  if (!IsDate())
  {
    return result;
  }

  CDate dateTmp;
  CStringArray array;

  if (!HasDateRef(NULL, &array))
  {
    return result;
  }

  result.append(array[0]);
  result.append(" since ");
  result.append(dateTmp.AsString("", true));
  result.append(" UTC");

  return result;

}
void CMainMenuWindowHandler::enter()
{
    CWindowHandler::enter();
    CGameEngine::getInstance()->getWindowManager()->clearHistory();

    IPfVersionDAO *versionDAO = CGameEngine::getInstance()->getCMasterDAOFactory()->getIPfVersionDAO();
    CPfVersion    *version = versionDAO->findByXVersion(1);
    CDate nowDate;
    m_currentDate->setText(nowDate.format("%d/%m/%Y"));
    m_versionDate->setText(version->getDDate().format("%d/%m/%Y"));
    m_version    ->setText(version->getSVersion());

    IPfGamesDAO*            gamesDAO    = CGameEngine::getInstance()->getCMasterDAOFactory()->getIPfGamesDAO();
    std::vector<CPfGames*> *gamesList   = gamesDAO->findByXFkUser(CGameEngine::getInstance()->getCurrentUser()->getXUser_str());

    if(gamesList != NULL) {
        if(!gamesList->empty()) {
            m_quickLoadButton->setEnabled(true);
        } else {
            m_quickLoadButton->setEnabled(false);
        }
        gamesDAO->freeVector(gamesList);
    } else {
        m_quickLoadButton->setEnabled(false);
    }

    delete version;

}
Пример #4
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());
      }
Пример #5
0
//----------------------------------------
bool CUnit::HasDateRef(CDate* dateRef /*= NULL*/, CStringArray* array /*= NULL*/) const
{
  if (!IsDate())
  {
    return false;
  }

  CStringArray ar;

  ar.ExtractStrings(GetText().c_str(), ' ');

  size_t len = ar.size();


  if (len <= 2)
  {
    return false;
  }

  int32_t index = ar.FindIndex("since");

  if (index < 0)
  {
    return false;
  }

  CDate dateTmp;

  int32_t result = BRATHL_ERROR;
  std::string strDate;

  for (uint32_t i = index + 1 ; i < ar.size() ; i++)
  {
    strDate.append(ar.at(i));
    strDate.append(" ");

  }

  strDate = CTools::StringTrim(strDate);
  
  result = dateTmp.SetDate(strDate.c_str());

  if (result == BRATHL_SUCCESS)
  {
    if (dateRef != NULL)
    {
      *dateRef = dateTmp;
    }
  }
  
  if (array != NULL)
  {
    array->Insert(ar);
  }

  return (result == BRATHL_SUCCESS);
}
Пример #6
0
CDate::ECompare CDate::Compare(const CDate& date) const
{
    if (IsStd()  &&  date.IsStd() ) {
        return GetStd().Compare(date.GetStd());
    } else if (IsStr()  &&  date.IsStr()  &&  GetStr() == date.GetStr()) {
        return eCompare_same;
    } else {
        return eCompare_unknown;
    }
}
Пример #7
0
bool CDate::WithinDays(CDate d, BYTE n)
{
	if( d > *this )
	{
		return (d.GetDayCount()-GetDayCount())<=n;
	}
	else
	{
		return (GetDayCount()-d.GetDayCount())<=n;
	}
}
Пример #8
0
CDate CDate::Now()
{
	CDate ret;
	time_t  v;
	time(&v);

	struct tm* t = localtime(&v);

	ret.SetDate(t->tm_year, t->tm_mon, t->tm_mday);
	return ret;
}
Пример #9
0
//----------------------------------------
void CSelectionCriteriaDlg::StoreCriteriaValueDatetime(CProduct* product, bool checkDefault /* = true */)
{
  if (product == NULL)
  {
    return;
  }

  if (!product->HasDatetimeCriteria())
  {
    return;
  }

  CCriteriaDatetime* criteria = product->GetDatetimeCriteria();
  criteria->SetDefaultValue();

  double defaultValue;
  CTools::SetDefaultValue(defaultValue);

  CDate dateMin;
  CDate dateMax;
  double min = 0.0;
  double max = 0.0;

  dateMin.InitDateZero();
  dateMax.SetDateNow();

/*
  CDate dateMin;
  CDate dateMax;
  dateMin.SetDefaultValue();
  dateMax.SetDefaultValue();

  GetCritDateMin()->GetValue(dateMin, defaultValue);
  GetCritDateMax()->GetValue(dateMax, defaultValue);
*/
  //GetCritDateMin()->GetValueAsDate(min, defaultValue, dateMin.Value(), dateMax.Value());
  //GetCritDateMax()->GetValueAsDate(max, defaultValue, dateMin.Value(), dateMax.Value());
  GetCritDateMin()->GetValueAsDate(min, defaultValue);
  GetCritDateMax()->GetValueAsDate(max, defaultValue);

  // to set right date string format
  GetCritDateMin()->SetValueAsDate(min, "");
  GetCritDateMax()->SetValueAsDate(max, "");

  criteria->Set(min, max);

}
Пример #10
0
IGame* CSinglePlayerGame::load(const CPfGames &game)
{
    LOG_DEBUG("CSinglePlayerGame::load");

	CSinglePlayerGame *singlePlayerGame = new CSinglePlayerGame(game);
	singlePlayerGame->loadGameEvents();

	CDate date = singlePlayerGame->m_optionManager->getGameCurrentDate();
	CGameEngine::getInstance()->getTimeManager()->setCurrentTime(date);

	date.setHour(23);
	date.setMin(59);
	date.setSec(59);
	CGameEngine::getInstance()->getEventManager()->addEvent(new CEndDayEvent(date));

	return singlePlayerGame;
}
/*void CEMGeneralSoldierExamination::OnYearKillfocus(){
	
} */
int CEMGeneralSoldierExamination::OnYearCheckValue()
{
	UpdateData(TRUE);
	if (m_nYear > 0)
	{
		CDateTime dt;
		CDate date;
		CString szTemp;

		dt.ParseDateTime(m_szFromDate);
		date = dt.GetDate();
		if (date.GetYear() != 1752)
		{
			dt.SetDate(m_nYear, date.GetMonth(), date.GetDay());
			m_szFromDate = dt.GetDateTime();
			szTemp.Format(_T("%.2d/%.2d/%.4d %.2d:%.2d"), dt.GetDate().GetDay(), dt.GetDate().GetMonth(), 
						  dt.GetDate().GetYear(), dt.GetTime().GetHour(), dt.GetTime().GetMinute());
			m_wndFromDate.SetWindowText(szTemp);
		}
		dt.ParseDateTime(m_szToDate);
		date = dt.GetDate();
		if (date.GetYear() != 1752)
		{
			dt.SetDate(m_nYear, date.GetMonth(), date.GetDay());
			m_szToDate = dt.GetDateTime();
			szTemp.Format(_T("%.2d/%.2d/%.4d %.2d:%.2d"), dt.GetDate().GetDay(), dt.GetDate().GetMonth(), 
						  dt.GetDate().GetYear(), dt.GetTime().GetHour(), dt.GetTime().GetMinute());
			m_wndToDate.SetWindowText(szTemp);
		}
	}
	UpdateData(FALSE);
	return 0;
} 
Пример #12
0
int main()
{
#ifdef __MSVC_DEBUG__
  InitLeakTest();
#endif

  CDate cdate;

  cout << "Enter a date: " << "\n";
  cin >> cdate;

  cout << "\n";
  cout << "Testing overloaded << operator..." << "\n";
  cout << "You Entered: " << cdate << "\n";

  cout << "\n";
  cout << "Testing c_str() function..." << "\n";
  char *buf = cdate.c_str();
  cout << "You Entered: " << buf << "\n";
  delete buf; // Free the memory allocated for the string

  cout << "\n";
  char sbuf[255];
  cout << "Enter a date string MM/DD/YYYY: ";
  cin >> sbuf;
  
  if(!cin) { 
    cout << "Bad input string" << "\n";
  }
  else {
    if(!cdate.SetDate(sbuf)) {
      cout << "Bad input value" << "\n";
    }
    else {
      buf = cdate.c_str();
      cout << "You Entered: " << buf << "\n";
      delete buf; // Free the memory allocated for the string
    }
  }

  return 0;
}
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;
}
void CEMOperationFosteringListC12::OnSetWindowEvents(){
	CMainFrame_E10 *pMF = (CMainFrame_E10*) AfxGetMainWnd();
	//m_wndYear.SetEvent(WE_CHANGE, _OnYearChangeFnc);
	//m_wndYear.SetEvent(WE_SETFOCUS, _OnYearSetfocusFnc);
	//m_wndYear.SetEvent(WE_KILLFOCUS, _OnYearKillfocusFnc);
	m_wndYear.SetEvent(WE_CHECKVALUE, _OnYearCheckValueFnc);
	m_wndReportPeriod.SetEvent(WE_SELENDOK, _OnReportPeriodSelendokFnc);
	//m_wndReportPeriod.SetEvent(WE_SETFOCUS, _OnReportPeriodSetfocusFnc);
	//m_wndReportPeriod.SetEvent(WE_KILLFOCUS, _OnReportPeriodKillfocusFnc);
	m_wndReportPeriod.SetEvent(WE_SELCHANGE, _OnReportPeriodSelectChangeFnc);
	m_wndReportPeriod.SetEvent(WE_LOADDATA, _OnReportPeriodLoadDataFnc);
	//m_wndReportPeriod.SetEvent(WE_ADDNEW, _OnReportPeriodAddNewFnc);
	m_wndObject.SetEvent(WE_SELENDOK, _OnObjectSelendokFnc);
	//m_wndObject.SetEvent(WE_SETFOCUS, _OnObjectSetfocusFnc);
	//m_wndObject.SetEvent(WE_KILLFOCUS, _OnObjectKillfocusFnc);
	m_wndObject.SetEvent(WE_SELCHANGE, _OnObjectSelectChangeFnc);
	m_wndObject.SetEvent(WE_LOADDATA, _OnObjectLoadDataFnc);
	//m_wndObject.SetEvent(WE_ADDNEW, _OnObjectAddNewFnc);
	//m_wndFromDate.SetEvent(WE_CHANGE, _OnFromDateChangeFnc);
	//m_wndFromDate.SetEvent(WE_SETFOCUS, _OnFromDateSetfocusFnc);
	//m_wndFromDate.SetEvent(WE_KILLFOCUS, _OnFromDateKillfocusFnc);
	m_wndFromDate.SetEvent(WE_CHECKVALUE, _OnFromDateCheckValueFnc);
	//m_wndToDate.SetEvent(WE_CHANGE, _OnToDateChangeFnc);
	//m_wndToDate.SetEvent(WE_SETFOCUS, _OnToDateSetfocusFnc);
	//m_wndToDate.SetEvent(WE_KILLFOCUS, _OnToDateKillfocusFnc);
	m_wndToDate.SetEvent(WE_CHECKVALUE, _OnToDateCheckValueFnc);
	m_wndPrintPreview.SetEvent(WE_CLICK, _OnPrintPreviewSelectFnc);
	m_wndExport.SetEvent(WE_CLICK, _OnExportSelectFnc);
	CDate dte;
	dte.ParseDate(pMF->GetSysDate());
	m_szFromDate = m_szToDate = pMF->GetSysDate();
	m_szFromDate += _T("00:00");
	m_szToDate += _T("23:59");
	m_nYear = dte.GetYear();
	m_szReportPeriodKey.Format(_T("%d"), dte.GetMonth());
	UpdateData(false);

}
Пример #15
0
int CDate::GetYearDiff( const CDate& otherDate ) const {
	if ( isNull || otherDate.isNull ) {
		return -1;
	}
	if ( otherDate.year > year ) {
		return -( otherDate.GetYearDiff( *this ) );
	} else {
		if ( otherDate.year < year ) {
			if ( otherDate.month < month ) {
				// this year counts
				return ( year - otherDate.year );
			} else {
				if ( otherDate.month == month ) {
					// this year may count
					if ( otherDate.day <= day ) {
						// this year counts
						return ( year - otherDate.year );
					} else {
						// this year doesn't count
						return ( year - otherDate.year ) - 1;
					}
				} else {
					// this year doesn't count
					return ( year - otherDate.year ) - 1;
				}
			}
		} else {
			if ( otherDate.month > month ) {
				return -1;
			} else {
				if ( otherDate.month < month ) {
					return 0;
				} else {
					if ( otherDate.day > day ) {
						return -1;
					} else {
						return 0;
						/*if ( otherDate.day < day ) {
							return 0;
						} else {
							return 0;
						}*/
					}
				}
			}
		}
	}
}
Пример #16
0
bool CDate::Parse(const core::string& str, CDate &tm)
{

	std::vector<core::string> tmpArray = core::StringUtil::Split(str, mT("/"));
	if (tmpArray.size() == 3)
	{
		int d = 0, m = 0, y = 0;
		d = core::StringConverter::toInt(tmpArray[0]);
		m = core::StringConverter::toInt(tmpArray[1]);
		y = core::StringConverter::toInt(tmpArray[2]);

		tm.SetDate(y, m, d);
		return true;
	}
	return false;
}
Пример #17
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));
}
Пример #18
0
int32_t CMission::Convert(uint32_t cycle, uint32_t pass, CDate& date) 
{
  int32_t result = BRATHL_SUCCESS;

  double dateJulian = 0.0;
  double dateJulianRef = 0.0;

  m_dateRef.Convert2DecimalJulian(dateJulianRef);
  double absRef = m_passRef + (m_cycleRef - 1) * m_nbPass;
  double abs = pass + (cycle -1) *  m_nbPass;
  double passLength = m_repeat / m_nbPass;
  
  dateJulian = dateJulianRef + (abs - absRef) * passLength;
  date.SetDateJulian(dateJulian);
  
  return result;

}
Пример #19
0
string ICitationBase::GetParenthesizedYear(const CDate& date)
{
    if (date.IsStd()) {
        string year;
        date.GetDate(&year, "(%4Y)");
        return year;
    } else if (date.IsStr()  &&  HasText(date.GetStr())
               &&  date.GetStr() != "?") {
        return '(' + date.GetStr().substr(0, 4) + ')';
    } else {
        return kEmptyStr;
    }
}
Пример #20
0
//----------------------------------------
int32_t CMission::Convert(CDate& date,  uint32_t& cycle, uint32_t& pass)
{
  double dateJulian = 0.0;
  double dateJulianRef = 0.0;
 
  int32_t result = BRATHL_SUCCESS;

  if (m_nbPass == 0)
  {
    return BRATHL_ERROR_INVALID_NB_PASS;
  }
  
  if (m_repeat == 0)
  {
    return BRATHL_ERROR_INVALID_REPETITION;
  }
/*  
  if ((cycle == NULL) || (size <= 0))
  {
    return BRATHL_ERROR_INVALID_CTODATE_PARAMETER;    
  }

*/
  date.Convert2DecimalJulian(dateJulian);
  m_dateRef.Convert2DecimalJulian(dateJulianRef);
  
  double absRef = m_passRef + (m_cycleRef - 1) * m_nbPass + 0.5;
  double passLength = m_repeat / m_nbPass;
  
  double deltaPass = (dateJulian - dateJulianRef) / passLength;
 
  double abs = absRef + deltaPass - 1;
  
  cycle = 1 + static_cast<int32_t>((abs) / m_nbPass);
  pass = 1 + static_cast<int32_t>((abs)) % m_nbPass;
  
      
  return result;
  
} 
Пример #21
0
void CSeasonGenerator::generateSeason(CSinglePlayerGame &game)
{
	CEventManager	*eventMngr	= CGameEngine::getInstance()->getEventManager();

	IDAOFactory                 *daoFactory = game.getIDAOFactory();
	IPfSeasonsDAO				*seasonsDAO					= daoFactory->getIPfSeasonsDAO();
	IPfCompetitionsBySeasonDAO	*competitionsBySeasonDAO	= daoFactory->getIPfCompetitionsBySeasonDAO();
	IPfTeamsDAO					*teamsDAO					= daoFactory->getIPfTeamsDAO();
	IPfTeamsByCompetitionsDAO	*teamsByCompetitionsDAO		= daoFactory->getIPfTeamsByCompetitionsDAO();

	CPfSeasons *season = seasonsDAO->findLastSeason();
	if( season==NULL || season->getXSeason_str()=="" ){
		throw PFEXCEPTION("[CSeasonGenerator::generateSeason] Last season was not found, new season generation is aborted.");
	}

	int year = season->getNYear()+1;
    std::ostringstream sseason;
    sseason << year << "/" << (year+1);

	// the min & max date necesary for the season events
    CDate minDate = CDate::MAX_DATE;
    CDate maxDate = CDate::MIN_DATE;

    // create the new season
	CPfSeasons newSeason;
	newSeason.setNYear(year);
	newSeason.setSSeason(sseason.str());
	daoFactory->getIPfSeasonsDAO()->insertReg(&newSeason);

	// retrieve the competitions associated with the last season
	std::vector<CPfCompetitionsBySeason*>	*competitionsBySeasonList = competitionsBySeasonDAO->findByXFkSeason(season->getXSeason_str());

	// for each competition, create a new competition by season and insert the relevant matches
	std::vector<CPfCompetitionsBySeason*>::iterator itCompetitionsBySeason;
	for( itCompetitionsBySeason=competitionsBySeasonList->begin(); itCompetitionsBySeason!=competitionsBySeasonList->end(); itCompetitionsBySeason++ ){
		CPfCompetitionsBySeason *competitionBySeason = *itCompetitionsBySeason;

		// create the new competition by season
		CPfCompetitionsBySeason *newCompetitionBySeason = new CPfCompetitionsBySeason();
		newCompetitionBySeason->setDBeginCompetition(getSameWeekDayOneYearLater(competitionBySeason->getDBeginCompetition()));
		newCompetitionBySeason->setDEndCompetition(getSameWeekDayOneYearLater(competitionBySeason->getDEndCompetition()));
		newCompetitionBySeason->setXFkCompetition_str(competitionBySeason->getXFkCompetition_str());
		newCompetitionBySeason->setXFkSeason_str(newSeason.getXSeason_str());
		competitionsBySeasonDAO->insertReg(newCompetitionBySeason);

		// retrieve the teams registered in previous season on the same competition
		std::vector<CPfTeams*> 				*teamsList = teamsDAO->findByXFKCompetitionAndXFKSeason(competitionBySeason->getXFkCompetition_str(), competitionBySeason->getXFkSeason_str());
		std::vector<CPfTeams*>::iterator 	itTeams;
		for( itTeams=teamsList->begin(); itTeams!=teamsList->end(); itTeams++ ){
			CPfTeams *team = *itTeams;

			// the team will be associate with the competition for the new season
			CPfTeamsByCompetitions *newTeamByCompetition = new CPfTeamsByCompetitions();
			newTeamByCompetition->setXFkCompetitionBySeason_str(newCompetitionBySeason->getXCompetitionBySeason_str());
			newTeamByCompetition->setXFkTeam_str(team->getXTeam_str());
			teamsByCompetitionsDAO->insertReg(newTeamByCompetition);

			delete newTeamByCompetition;
		}

		eventMngr->addEvent(new CStartCompetitionEvent(newCompetitionBySeason->getDBeginCompetition()));

		//Shuffle teams to create random calendar
		std::random_shuffle(teamsList->begin(), teamsList->end());

		generateLeagueMatches(game, *newCompetitionBySeason, teamsList); // TODO: Maybe not all competitions are leagues
		eventMngr->addEvent(new CEndCompetitionEvent(newCompetitionBySeason->getDEndCompetition()));

		// Retrieve the min & max date for the season events
		if( newCompetitionBySeason->getDBeginCompetition()<minDate ){
			minDate = newCompetitionBySeason->getDBeginCompetition();
		}
		if( newCompetitionBySeason->getDEndCompetition()>maxDate ){
			maxDate = newCompetitionBySeason->getDEndCompetition();
		}

		teamsDAO->freeVector(teamsList);
		delete newCompetitionBySeason;
	}

	minDate.setSec(minDate.getSec()-1);
	maxDate.setSec(maxDate.getSec()+1);

	// enqueue the start & end season events
	eventMngr->addEvent(new CStartSeasonEvent(minDate));
	eventMngr->addEvent(new CEndSeasonEvent(maxDate));
	game.getOptionManager()->setGameCurrentSeason(newSeason.getXSeason());

	competitionsBySeasonDAO->freeVector(competitionsBySeasonList);
	delete season;
}
Пример #22
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;
}
Пример #23
0
void CPfCoachContracts::setDBegin(const CDate &DBegin)
{
    m_DBegin = DBegin.getTimestamp();
}
Пример #24
0
//----------------------------------------
void CProductErs::ComputeHighResolutionFields(CDataSet* dataSet, double deltaLat, double deltaLon)
{
  // Save current recordset pointer
  CRecordSet* currentRecordSetOld = dataSet->GetCurrentRecordSet();

  //dataSet->SetCurrentRecordSet(dataSet->GetFirstRecordSet());

  CFieldSetDbl *fieldSetLat = NULL;
  CFieldSetDbl *fieldSetLon = NULL;
  CFieldSetDbl *fieldSetTimeStampSecond = NULL;
  CFieldSetDbl *fieldSetTimeStampMicrosecond = NULL;

  int32_t count = dataSet->size();

  for (int32_t index = 0 ; index < count ; index++)
  {
    dataSet->SetCurrentRecordSet(index);

    fieldSetLat = dataSet->GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_latitudeFieldName) );
    fieldSetLon = dataSet->GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_longitudeFieldName) );
    fieldSetTimeStampSecond = dataSet->GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_timeStampSecondFieldName) );
    fieldSetTimeStampMicrosecond = dataSet->GetFieldSetAsDbl( m_fieldNameEquivalence.Exists(m_timeStampMicrosecondFieldName) );

    // Compute latitude
    if (fieldSetLat != NULL)
    {
      fieldSetLat->m_value = CTools::Plus(fieldSetLat->m_value, 
                                          CTools::Multiply(deltaLat, 
                                                           static_cast<double>(index - m_refPoint)));
    }

    // Compute longitude
    if (fieldSetLon != NULL)
    {
      //fieldSetLon->m_value = CTools::NormalizeLongitude(-180,  
      //                                                  CTools::Plus(fieldSetLon->m_value, 
      //                                                               CTools::Multiply(deltaLon, 
      //                                                                                static_cast<double>(index - m_refPoint))));
      fieldSetLon->m_value = CTools::Plus(fieldSetLon->m_value, 
                                          CTools::Multiply(deltaLon, 
                                                           static_cast<double>(index - m_refPoint)));
    }

    // Compute timestamp
    
    // WARNING -  fieldSetTimeStampSecond, fieldSetTimeStampMicrosecond are converted to SI
    // after they have been read. So their value are stated in seconds
    
    // fieldSetTimeStampSecond = number of seconds from reference SI unit (i.e. 1950-01-01 00:00:00.0)
    
    // fieldSetTimeStampMicrosecond = number of museconds  within the seconds ( < 1 second)
    
    double nbSeconds = 0;

    if (fieldSetTimeStampSecond != NULL)
    {
      nbSeconds = CTools::Plus(nbSeconds, fieldSetTimeStampSecond->m_value);
    }

    if (fieldSetTimeStampMicrosecond != NULL)
    {
      nbSeconds = CTools::Plus(nbSeconds, fieldSetTimeStampMicrosecond->m_value);
    }
    
    nbSeconds = CTools::Plus(nbSeconds, 
                             CTools::Multiply(m_deltaTimeHighResolution, 
                                              static_cast<double>(index - m_refPoint)));
    double seconds;
    double muSeconds;

    CDate timeStamp;
    timeStamp.SetDate(nbSeconds);

    //WARNING At this point,
    // fieldSetTimeStampSecond is stated  in number of seconds and fieldSetTimeStampMicrosecond in numbers of microseconds
    timeStamp.Convert2SM(seconds,
                         muSeconds);

    // WARNING -  fieldSetTimeStampSecond, fieldSetTimeStampMicrosecond are converted to SI
    // after they have been read. So their value are stated in seconds
    //
    //WARNING At this point, muSeconds is stated in numbers of microseconds
    //
    // ====> Convert again muSeconds to a number of seconds     

    if (fieldSetTimeStampSecond != NULL)
    {
      fieldSetTimeStampSecond->m_value = seconds;
    }

    if (fieldSetTimeStampMicrosecond != NULL)
    {
      fieldSetTimeStampMicrosecond->m_value = muSeconds / 1.0E+6;
    }
      

    /*  
    // WARNING -  convert fieldSetTimeStampSecond, fieldSetTimeStampMicrosecond in SI
    // after they have been read. So their value are stated in seconds
    CUnit unit = fieldSetTimeStampSecond->GetField()->GetUnit();
    fieldSetTimeStampSecond->m_value = unit.Convert(fieldSetTimeStampSecond->m_value);

    unit = fieldSetTimeStampMicrosecond->GetField()->GetUnit();
    fieldSetTimeStampMicrosecond->m_value = unit.Convert(fieldSetTimeStampMicrosecond->m_value);
    */
  }

  // Restore current recordset pointer
  dataSet->SetCurrentRecordSet(currentRecordSetOld);
}
Пример #25
0
void CPfMatches::setDMatch(CDate &DMatch)
{
    m_DMatch = DMatch.getTimestamp();
}
Пример #26
0
void CPfCoachContracts::setDEnd(const CDate &DEnd)
{
    m_DEnd = DEnd.getTimestamp();
}
void CCEMPatientStatistic::OnReportPeriodSelendok(){
	CString tmpStr;
	CDate dte;
	UpdateData(true);
	int nMonth = ToInt(m_szReportPeriodKey);
	if(nMonth > 0 && nMonth <= 12)
	{
		m_szFromDate.Format(_T("%.4d/%.2d/01"), m_nYear, nMonth);
		dte.ParseDate(m_szFromDate);
		m_szToDate.Format(_T("%.4d/%.2d/%.2d 23:59"), m_nYear, nMonth, dte.GetMonthLastDay());
	}
	if(nMonth == 13){
		m_szFromDate.Format(_T("%.4d/01/01"), m_nYear);
		tmpStr.Format(_T("%.4d/03/01"), m_nYear);
		dte.ParseDate(tmpStr);
		m_szToDate.Format(_T("%.4d/03/%.2d 23:59" ), m_nYear,  dte.GetMonthLastDay());
	}
	if(nMonth == 14){
		m_szFromDate.Format(_T("%.4d/04/01"), m_nYear);
		tmpStr.Format(_T("%.4d/06/01"), m_nYear);
		dte.ParseDate(tmpStr);
		m_szToDate.Format(_T("%.4d/06/%.2d 23:59"), m_nYear, dte.GetMonthLastDay());
	}
	if(nMonth == 15){
		m_szFromDate.Format(_T("%.4d/07/01"), m_nYear);
		tmpStr.Format(_T("%.4d/09/01"), m_nYear);
		dte.ParseDate(tmpStr);
		m_szToDate.Format(_T("%.4d/09/%.2d 23:59"), m_nYear, dte.GetMonthLastDay());
	}
	if(nMonth == 16){
		m_szFromDate.Format(_T("%.4d/10/01"), m_nYear);
		tmpStr.Format(_T("%.4d/10/01"), m_nYear);
		dte.ParseDate(tmpStr);
		m_szToDate.Format(_T("%.4d/12/%.2d 23:59"), m_nYear, dte.GetMonthLastDay());
	}
	if(nMonth == 17){
		m_szFromDate.Format(_T("%.4d/01/01"), m_nYear);
		tmpStr.Format(_T("%.4d/12/01"), m_nYear);
		dte.ParseDate(tmpStr);
		m_szToDate.Format(_T("%.4d/12/%.2d 23:59"), m_nYear, dte.GetMonthLastDay());		
	}	
	UpdateData(false);		 
}
Пример #28
0
//----------------------------------------
int32_t CBratProcessExportAscii::Execute(string& msg)
{ 

  int32_t result = BRATHL_SUCCESS;

  CDate startExec;
  startExec.SetDateNow();

  if (m_product == NULL)
  {
	  throw CException("PROGRAM ERROR: product is NULL (CBratProcessExportAscii::Execute) - Perhaps, initialization has not been called",
			   BRATHL_LOGIC_ERROR);
  }


  m_product->SetExpandArray(m_expandArray);


  // Always 'expand array' for Netcdf Product (To show data in column and data value by line)
  m_product->SetForceReadDataOneByOne(true);

  m_writeHeader = true;

  uint32_t nbFiles = m_inputFiles.size();
  uint32_t cptFile = 0;

  CStringArray::iterator itFile;

  //for each file, read and write data
  for (itFile = m_inputFiles.begin() ; itFile != m_inputFiles.end() ; itFile++)
  {
    cptFile++;

    CTrace::Tracer(1,"File %d/%d - Reading record data from %s ... and registering data ...",
                   cptFile, nbFiles, (*itFile).c_str());

    // open file an set record name and list of field to read
    m_product->SetFieldSpecificUnits(m_fieldSpecificUnit);
    m_product->Open(*itFile, m_recordName);

    m_product->SetListFieldToRead(m_listFieldsToRead, false);

    // Get the number of record for the default record name (set in Open method of CProduct above)
    int32_t nRecords = m_product->GetNumberOfRecords();

    for (int32_t iRecord = 0 ; iRecord < nRecords ; iRecord++)
    {
      //Read fields for the record name  (listof field and record name are set in Open method of CProduct above)
      m_product->ReadBratRecord(iRecord);

      WriteData();
      //m_writeHeader = false;
    }

    m_product->Close();

  }

  if (m_product->GetSkippedRecordCount() > 0)
  {
    string msg = CTools::Format("WARNING - %d input data records have been skipped due to inconsistency between two measures",
                                m_product->GetSkippedRecordCount());
    CTrace::Tracer(1, msg);
  }

  CTrace::Tracer(1,"End processing - OK");



  CDate endExec;
  endExec.SetDateNow();
  
  CTrace::Tracer(1, CTools::Format("Processing time: %.3f seconds (%.2f minutes)\n", 
                                  (endExec - startExec),
                                  (endExec - startExec) / 60.0));

 
  return result;
}
CTimevector::CTimevector(const CDate &d)
: m_days(d.getDaysPast()), m_mseconds(0)
{}
CTimevector::CTimevector(const CDate &d, const CTime &z)
: m_days(d.getDaysPast()), m_mseconds(z.getMillisecondsPast())
{}