mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 17:30:44 +02:00
#318: Logger local time doesn't automatically account for DST (PatternFormatter)
This commit is contained in:
@@ -34,18 +34,16 @@ const std::string PatternFormatter::PROP_TIMES = "times";
|
||||
|
||||
|
||||
PatternFormatter::PatternFormatter():
|
||||
_localTime(false),
|
||||
_localTimeOffset(Timestamp::resolution()*(Timezone::utcOffset() + Timezone::dst()))
|
||||
_localTime(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PatternFormatter::PatternFormatter(const std::string& format):
|
||||
_localTime(false),
|
||||
_localTimeOffset(Timestamp::resolution()*(Timezone::utcOffset() + Timezone::dst())),
|
||||
_pattern(format)
|
||||
{
|
||||
ParsePattern();
|
||||
parsePattern();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +58,8 @@ void PatternFormatter::format(const Message& msg, std::string& text)
|
||||
bool localTime = _localTime;
|
||||
if (localTime)
|
||||
{
|
||||
timestamp += _localTimeOffset;
|
||||
timestamp += Timezone::utcOffset()*Timestamp::resolution();
|
||||
timestamp += Timezone::dst()*Timestamp::resolution();
|
||||
}
|
||||
DateTime dateTime = timestamp;
|
||||
for (std::vector<PatternAction>::iterator ip = _patternActions.begin(); ip != _patternActions.end(); ++ip)
|
||||
@@ -124,7 +123,8 @@ void PatternFormatter::format(const Message& msg, std::string& text)
|
||||
if (!localTime)
|
||||
{
|
||||
localTime = true;
|
||||
timestamp += _localTimeOffset;
|
||||
timestamp += Timezone::utcOffset()*Timestamp::resolution();
|
||||
timestamp += Timezone::dst()*Timestamp::resolution();
|
||||
dateTime = timestamp;
|
||||
}
|
||||
break;
|
||||
@@ -132,7 +132,8 @@ void PatternFormatter::format(const Message& msg, std::string& text)
|
||||
}
|
||||
}
|
||||
|
||||
void PatternFormatter::ParsePattern()
|
||||
|
||||
void PatternFormatter::parsePattern()
|
||||
{
|
||||
_patternActions.clear();
|
||||
std::string::const_iterator it = _pattern.begin();
|
||||
@@ -196,7 +197,7 @@ void PatternFormatter::setProperty(const std::string& name, const std::string& v
|
||||
if (name == PROP_PATTERN)
|
||||
{
|
||||
_pattern = value;
|
||||
ParsePattern();
|
||||
parsePattern();
|
||||
}
|
||||
else if (name == PROP_TIMES)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user