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:
2010-10-09 20:27:45 +00:00
parent 69c634d53f
commit 07511a2eb0
7 changed files with 62 additions and 12 deletions

View File

@@ -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;
}