本文整理汇总了C++中CDate::SetDate方法的典型用法代码示例。如果您正苦于以下问题:C++ CDate::SetDate方法的具体用法?C++ CDate::SetDate怎么用?C++ CDate::SetDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDate
的用法示例。
在下文中一共展示了CDate::SetDate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: Parse
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;
}
示例4: 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;
}
示例5: ComputeHighResolutionFields
//----------------------------------------
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
//.........这里部分代码省略.........