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


C++ CDate类代码示例

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


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

示例1: GetArgs

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;
}
开发者ID:svn2github,项目名称:ncbi_tk,代码行数:29,代码来源:test_date.cpp

示例2:

//----------------------------------------
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;

}
开发者ID:BRAT-DEV,项目名称:main,代码行数:27,代码来源:Unit.cpp

示例3: enter

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;

}
开发者ID:dividio,项目名称:projectfootball,代码行数:29,代码来源:CMainMenuWindowHandler.cpp

示例4: _d0

      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());
      }
开发者ID:RemiLacroix-IDRIS,项目名称:XIOS,代码行数:9,代码来源:calendar.cpp

示例5: HasDateRef

//----------------------------------------
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);
}
开发者ID:BRAT-DEV,项目名称:main,代码行数:58,代码来源:Unit.cpp

示例6: Compare

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;
    }
}
开发者ID:swuecho,项目名称:igblast,代码行数:10,代码来源:Date.cpp

示例7: WithinDays

bool CDate::WithinDays(CDate d, BYTE n)
{
	if( d > *this )
	{
		return (d.GetDayCount()-GetDayCount())<=n;
	}
	else
	{
		return (GetDayCount()-d.GetDayCount())<=n;
	}
}
开发者ID:sverhagen,项目名称:trillian-bdc,代码行数:11,代码来源:Date.CPP

示例8: Now

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;
}
开发者ID:yingzhang536,项目名称:mrayy-Game-Engine,代码行数:11,代码来源:DateTime.cpp

示例9: StoreCriteriaValueDatetime

//----------------------------------------
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);

}
开发者ID:adakite,项目名称:main,代码行数:48,代码来源:SelectionCriteriaDlg.cpp

示例10: LOG_DEBUG

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;
}
开发者ID:dividio,项目名称:projectfootball,代码行数:17,代码来源:CSinglePlayerGame.cpp

示例11: UpdateData

/*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;
} 
开发者ID:smithgold53,项目名称:HMSReportForms,代码行数:36,代码来源:EMGeneralSoldierExamination.cpp

示例12: main

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;
}
开发者ID:datareel,项目名称:datareel_4_visual_studio,代码行数:42,代码来源:testprog.cpp

示例13: 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

示例14: AfxGetMainWnd

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);

}
开发者ID:smithgold53,项目名称:HMSReportForms,代码行数:38,代码来源:EMOperationFosteringListC12.cpp

示例15: GetYearDiff

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;
						}*/
					}
				}
			}
		}
	}
}
开发者ID:bklimt,项目名称:StudentInfo,代码行数:48,代码来源:Date.cpp


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