mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 02:18:04 +01:00
trunk/branch integration: DateTimeFormatter %s
This commit is contained in:
@@ -16,14 +16,14 @@
|
|||||||
// execute, and transmit the Software, and to prepare derivative works of the
|
// 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
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
// do so, all subject to the following:
|
// do so, all subject to the following:
|
||||||
//
|
//
|
||||||
// The copyright notices in the Software and this entire statement, including
|
// The copyright notices in the Software and this entire statement, including
|
||||||
// the above license grant, this restriction and the following disclaimer,
|
// 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
|
// 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
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
// works are solely in the form of machine-executable object code generated by
|
// works are solely in the form of machine-executable object code generated by
|
||||||
// a source language processor.
|
// a source language processor.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
// 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)
|
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)
|
void DateTimeFormatter::append(std::string& str, const DateTime& dateTime, const std::string& fmt, int timeZoneDifferential)
|
||||||
{
|
{
|
||||||
std::string::const_iterator it = fmt.begin();
|
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.hour(), 2); break;
|
||||||
case 'h': NumberFormatter::append0(str, dateTime.hourAMPM(), 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 '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 '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); break;
|
||||||
case 'i': NumberFormatter::append0(str, dateTime.millisecond(), 3); break;
|
case 's': NumberFormatter::append0(str, dateTime.second(), 2);
|
||||||
case 'c': NumberFormatter::append(str, dateTime.millisecond()/100); break;
|
str += '.';
|
||||||
case 'F': NumberFormatter::append0(str, dateTime.millisecond()*1000 + dateTime.microsecond(), 6); break;
|
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': tzdISO(str, timeZoneDifferential); break;
|
||||||
case 'Z': tzdRFC(str, timeZoneDifferential); break;
|
case 'Z': tzdRFC(str, timeZoneDifferential); break;
|
||||||
default: str += *it;
|
default: str += *it;
|
||||||
@@ -163,7 +168,7 @@ void DateTimeFormatter::tzdRFC(std::string& str, int timeZoneDifferential)
|
|||||||
str += '-';
|
str += '-';
|
||||||
NumberFormatter::append0(str, -timeZoneDifferential/3600, 2);
|
NumberFormatter::append0(str, -timeZoneDifferential/3600, 2);
|
||||||
NumberFormatter::append0(str, (-timeZoneDifferential%3600)/60, 2);
|
NumberFormatter::append0(str, (-timeZoneDifferential%3600)/60, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else str += "GMT";
|
else str += "GMT";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user