trunk/branch integration: DateTimeFormatter %s

This commit is contained in:
Marian Krivos 2011-08-23 06:41:17 +00:00
parent b8f2fe9efe
commit 4cc807d67d

View File

@ -16,14 +16,14 @@
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
@ -45,9 +45,10 @@ namespace Poco {
void DateTimeFormatter::append(std::string& str, const LocalDateTime& dateTime, const std::string& fmt)
{
DateTimeFormatter::append(str, dateTime.utc(), fmt, dateTime.tzd());
DateTimeFormatter::append(str, dateTime.utc(), fmt, dateTime.tzd());
}
void DateTimeFormatter::append(std::string& str, const DateTime& dateTime, const std::string& fmt, int timeZoneDifferential)
{
std::string::const_iterator it = fmt.begin();
@ -75,12 +76,16 @@ void DateTimeFormatter::append(std::string& str, const DateTime& dateTime, const
case 'H': NumberFormatter::append0(str, dateTime.hour(), 2); break;
case 'h': NumberFormatter::append0(str, dateTime.hourAMPM(), 2); break;
case 'a': str.append(dateTime.isAM() ? "am" : "pm"); break;
case 'A': str.append(dateTime.isAM() ? "AM" : "PM"); break;
case 'M': NumberFormatter::append0(str, dateTime.minute(), 2); break;
case 'S': NumberFormatter::append0(str, dateTime.second(), 2); break;
case 'i': NumberFormatter::append0(str, dateTime.millisecond(), 3); break;
case 'c': NumberFormatter::append(str, dateTime.millisecond()/100); break;
case 'F': NumberFormatter::append0(str, dateTime.millisecond()*1000 + dateTime.microsecond(), 6); break;
case 'A': str.append(dateTime.isAM() ? "AM" : "PM"); break;
case 'M': NumberFormatter::append0(str, dateTime.minute(), 2); break;
case 'S': NumberFormatter::append0(str, dateTime.second(), 2); break;
case 's': NumberFormatter::append0(str, dateTime.second(), 2);
str += '.';
NumberFormatter::append0(str, dateTime.millisecond()*1000 + dateTime.microsecond(), 6);
break;
case 'i': NumberFormatter::append0(str, dateTime.millisecond(), 3); break;
case 'c': NumberFormatter::append(str, dateTime.millisecond()/100); break;
case 'F': NumberFormatter::append0(str, dateTime.millisecond()*1000 + dateTime.microsecond(), 6); break;
case 'z': tzdISO(str, timeZoneDifferential); break;
case 'Z': tzdRFC(str, timeZoneDifferential); break;
default: str += *it;
@ -163,7 +168,7 @@ void DateTimeFormatter::tzdRFC(std::string& str, int timeZoneDifferential)
str += '-';
NumberFormatter::append0(str, -timeZoneDifferential/3600, 2);
NumberFormatter::append0(str, (-timeZoneDifferential%3600)/60, 2);
}
}
}
else str += "GMT";
}