fixed: DbBase::ConvertTime(tm) should not have been used in this way as it was
(it uses a static buffer) now DbTextStream can get tm struct so you don't have to use ConvertTime git-svn-id: svn://ttmath.org/publicrep/winix/trunk@662 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -54,7 +54,7 @@ DbTextStream & DbTextStream::PutText(const std::string & str)
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const DbTextStream::RawText<const char*> & raw)
|
||||
DbTextStream & DbTextStream::operator<<(const RawText<const char*> & raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ DbTextStream & DbTextStream::operator<<(const DbTextStream::RawText<const char*>
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(DbTextStream::RawText<std::string> raw)
|
||||
DbTextStream & DbTextStream::operator<<(RawText<std::string> raw)
|
||||
{
|
||||
return PutText(raw.par.c_str());
|
||||
}
|
||||
@@ -131,6 +131,15 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const RawText<tm> & t)
|
||||
{
|
||||
buffer += ConvertTime(t.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -357,7 +366,36 @@ return *this;
|
||||
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const tm & t)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
buffer += '\'';
|
||||
buffer += ConvertTime(t);
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * DbTextStream::ConvertTime(const tm & t)
|
||||
{
|
||||
// not thread safe
|
||||
static char buffer[100];
|
||||
|
||||
sprintf(buffer, "%04d-%02d-%02d %02d:%02d:%02d",
|
||||
t.tm_year + 1900,
|
||||
t.tm_mon + 1,
|
||||
t.tm_mday,
|
||||
t.tm_hour,
|
||||
t.tm_min,
|
||||
t.tm_sec);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user