From: Mikko Rasa Date: Mon, 30 May 2011 19:58:39 +0000 (+0300) Subject: Use format instead of stringstream in DateTime X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c0319d7fb558683afdcf523660a40355b6bf0955;p=libs%2Fcore.git Use format instead of stringstream in DateTime --- diff --git a/source/time/datetime.cpp b/source/time/datetime.cpp index 23d0f2a..d609b29 100644 --- a/source/time/datetime.cpp +++ b/source/time/datetime.cpp @@ -6,9 +6,8 @@ Distributed under the LGPL */ #include -#include -#include #include +#include #include "datetime.h" #include "timestamp.h" #include "units.h" @@ -255,8 +254,7 @@ TimeStamp DateTime::get_timestamp() const string DateTime::format(const string &fmt) const { - ostringstream ss; - ss.fill('0'); + string result; for(string::const_iterator i=fmt.begin(); i!=fmt.end(); ++i) { if(*i=='%') @@ -265,31 +263,31 @@ string DateTime::format(const string &fmt) const if(i==fmt.end()) break; else if(*i=='d') - ss<=12) ? "PM" : "AM"); + result += ((hour>=12) ? "PM" : "AM"); else if(*i=='S') - ss<(offs/Time::min)); - ss<<(offs