本文整理汇总了C++中DateTime::Seconds方法的典型用法代码示例。如果您正苦于以下问题:C++ DateTime::Seconds方法的具体用法?C++ DateTime::Seconds怎么用?C++ DateTime::Seconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime::Seconds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsSet
bool WorkTime::IsSet() const
{
MYSQL_RES* res;
string sql;
DateTime* dayStart = new DateTime();
DateTime* dayEnd = new DateTime();
dayStart->Hour(0);
dayStart->Minute(0);
dayStart->Minute(0);
dayStart->DateToTimestamp();
dayEnd->Hour(23);
dayEnd->Minute(59);
dayEnd->Seconds(59);
dayEnd->DateToTimestamp();
sql = "SELECT `id` FROM `" + this->table + "` WHERE "
+ "`user` = " + NumberToStringConverter<int>::Convert(this->GetUser()->GetId()) + " "
+ "AND `day` > " + NumberToStringConverter<int>::Convert(dayStart->Timestamp()) + " "
+ "AND `day` < " + NumberToStringConverter<int>::Convert(dayEnd->Timestamp()) + " "
+ "LIMIT 0, 2";
res = this->connector->Query(sql, SELECT);
if(mysql_num_rows(res) != 0) {
return true;
}
else {
return false;
}
}
示例2: ImportGPSDataGPGGA
void ImportGPSDataGPGGA (const KKStr& fileName)
{
RunLog log;
DataBasePtr dbConn = new DataBase (log);
ifstream i (fileName.Str ());
if (!i.is_open ())
{
log.Level (-1) << endl << endl
<< "ImpotrtGPSData Could not open file[" << fileName << "]" << endl
<< endl;
return;
}
log.Level (10) << endl << endl << endl << endl << endl
<< "ImpotrtGPSData FileName[" << fileName << "]" << endl << endl
<< endl;
char buff[20480];
bool firstPass = true;
int lastMinute = 0;
int linesRead = 0;
KKStr ln (256);
DateTime lastDateTime;
while (i.getline (buff, sizeof (buff)))
{
linesRead++;
ln = buff;
ln.TrimLeft ();
if (!ln.LocateStr ("GPGGA"))
continue;
VectorKKStr fields = ln.Parse (",");
if (fields.size () < 8)
continue;
if (!fields[2].EqualIgnoreCase ("$GPGGA"))
continue;
/*
0 1 2 3 4 5 6 7 8
06/01/2010, 23:59:59.818, $GPGGA, 235958, 2840.927, N, 08828.458, W, 2, 09,22.10,0,M,,,14,0000*12
06/02/2010, 00:00:10.818, $GPGGA, 000009, 2840.931, N, 08828.482, W, 1, 09,0.89,0,M,,,,*2D
06/02/2010, 00:00:21.802, $GPGGA, 000020, 2840.929, N, 08828.505, W, 1, 09,0.89,0,M,,,,*21
06/02/2010, 00:00:31.818, $GPGGA, 000030, 2840.924, N, 08828.526, W, 1, 09,0.89,0,M,,,,*2C
06/02/2010, 00:00:42.818, $GPGGA, 000041, 2840.917, N, 08828.547, W, 1, 09,0.89,0,M,,,,*2D
06/02/2010, 00:00:53.802, $GPGGA, 000052, 2840.906, N, 08828.568, W, 1, 09,1.00,0,M,,,,*22
06/02/2010, 00:01:03.802, $GPGGA, 000102, 2840.895, N, 08828.585, W, 1, 09,0.89,0,M,,,,*2E
06/02/2010, 00:01:13.818, $GPGGA, 000112, 2840.883, N, 08828.600, W, 1, 09,0.89,0,M,,,,*26
*/
KKStr dateStr = fields[0];
KKStr timeStr = fields[1];
KKStr latStr = fields[4];
KKStr logStr = fields[6];
auto x = latStr.LocateCharacter ('.');
if (!x)
continue;
KKStr latMinStr = latStr.SubStrPart (x - 2);
KKStr latDegStr = latStr.SubStrSeg (0, x - 2);
double latitude = latDegStr.ToDouble () + latMinStr.ToDouble () / 60.0;
if (fields[5].EqualIgnoreCase ("S"))
latitude = 0.0 - latitude;
x = logStr.LocateCharacter ('.');
if (!x)
continue;
KKStr logMinStr = logStr.SubStrPart (x - 2);
KKStr logDegStr = logStr.SubStrSeg (0, x - 2);
double longitude = logDegStr.ToDouble () + logMinStr.ToDouble () / 60.0;
if (fields[7].EqualIgnoreCase ("W"))
longitude = 0.0 - longitude;
DateType gmtDate (dateStr);
TimeType gmtTime (timeStr);
DateTime gmtDateTime (gmtDate, gmtTime);
DateTime localTime = gmtDateTime;
localTime.HoursAdd (-4);
DateTime startDT = localTime;
DateTime endDT = localTime;
if (firstPass)
{
firstPass = false;
startDT.SecondsAdd (-180);
}
//.........这里部分代码省略.........
示例3: ImpotrtGPSData
void ImpotrtGPSData (const KKStr& fileName)
{
RunLog log;
DataBasePtr dbConn = new DataBase (log);
ifstream i (fileName.Str ());
if (!i.is_open ())
{
log.Level (-1) << endl << endl
<< "ImpotrtGPSData Could not open file[" << fileName << "]" << endl
<< endl;
return;
}
log.Level (10) << endl << endl << endl << endl << endl
<< "ImpotrtGPSData FileName[" << fileName << "]" << endl << endl
<< endl;
char buff[20480];
bool firstPass = true;
int lastHour = 0;
DateTime lastDateTime;
while (i.getline (buff, sizeof (buff)))
{
KKStr ln = buff;
ln.TrimLeft ();
char ch = ln[0];
if ((ch < '0') || (ch > '9'))
continue;
KKStr dateStr = ln.ExtractToken2 (",");
KKStr timeStr = ln.ExtractToken2 (",");
KKStr WXTP_TaStr = ln.ExtractToken2 (",");
KKStr WXTS_TaStr = ln.ExtractToken2 (",");
KKStr WXTS_PaStr = ln.ExtractToken2 (",");
KKStr WXTP_PaStr = ln.ExtractToken2 (",");
KKStr dec_latStr = ln.ExtractToken2 (",");
KKStr dec_lonStr = ln.ExtractToken2 (",");
KKStr cogStr = ln.ExtractToken2 (",");
KKStr sogStr = ln.ExtractToken2 (",");
DateType gmtDate (dateStr);
TimeType gmtTime (timeStr);
DateTime gmtDateTime (gmtDate, gmtTime);
DateTime localTime = gmtDateTime;
localTime.HoursAdd (-4);
DateTime startDT = localTime;
DateTime endDT = localTime;
if (firstPass)
{
firstPass = false;
startDT.SecondsAdd (-180);
}
else
{
DateTime deltaDT = localTime - lastDateTime;
long deltaSecs = (long)deltaDT.Seconds ();
startDT.SecondsAdd (-(deltaSecs / 2));
}
endDT.SecondsAdd (120);
dbConn->InstrumentDataUpdateLatitudeAndLongitude (startDT, endDT, dec_latStr.ToDouble (), dec_lonStr.ToDouble ());
lastDateTime = localTime;
if (gmtTime.Minute () != lastHour)
{
lastHour = gmtTime.Hour ();
log.Level (10) << "File[" << osGetRootName (fileName) << "] GMT Time[" << gmtDate.MMM_DD_YYYY () << " - " << gmtTime.HH_MM_SS () << "]" << endl;
}
}
i.close ();
delete dbConn;
dbConn = NULL;
} /* ImpotrtGPSData */
示例4: if
void MergeFeatureFiles::Main ()
{
if (Abort ())
return;
{
// Will first load source files.
uint srcIdx = 0;
for (srcIdx = 0; srcIdx < srcFileNames.size (); srcIdx++)
{
bool cancelFlag = false;
bool successful = false;
bool changesMade = false;
KKStr srcFileName = srcFileNames[srcIdx];
FeatureFileIOPtr srcFormat = srcFormats [srcIdx];
MLClassList classes;
FeatureVectorListPtr s = NULL;
s = srcFormat->LoadFeatureFile (srcFileName, classes, -1, cancelFlag, successful, changesMade, log);
if ((s == NULL) || (!successful))
{
log.Level (-1) << endl << endl
<< "MergeFeatureFiles::Main ***ERROR*** Could not load file[" << srcFileName << "]" << endl
<< endl;
delete s; s = NULL;
Abort (true);
return;
}
if (!srcData)
srcData = new FeatureVectorList (s->FileDesc (), true);
if ((*(s->FileDesc ())) != (*(srcData->FileDesc ())))
{
// The last source file read does not have the same attribute sets as previous feature files already read.
log.Level (-1) << endl << endl
<< "MergeFeatureFiles::Main ***ERROR*** Feature File[" << srcFileName << "] does not have the same Attributes as previous feature files already read in." << endl
<< endl;
Abort (true);
delete s; s = NULL;
return;
}
srcData->AddQueue (*s);
s->Owner (false);
delete s;
}
}
if (!Abort ())
{
if (randomize)
{
DateTime dt = osGetLocalDateTime ();
srcData->RandomizeOrder (dt.Seconds ());
srcData->RandomizeOrder ();
}
if (stratify)
{
FeatureVectorListPtr stratifiedSrc = srcData->StratifyAmoungstClasses (numOfFolds, log);
srcData->Owner (false);
stratifiedSrc->Owner (true);
delete srcData;
srcData = stratifiedSrc;
stratifiedSrc = NULL;
}
bool cancelFlag = false;
bool successful = false;
uint numExamplesWritten = 0;
destFormat->SaveFeatureFile (destFileName, srcData->AllFeatures (), *srcData, numExamplesWritten, cancelFlag, successful, log);
if (!successful)
{
log.Level (-1) << endl << endl
<< "MergeFeatureFiles::Main ***ERROR*** Could not save to file[" << destFileName << "]" << endl
<< endl;
Abort (true);
}
}
} /* Main */