#318: Logger local time doesn't automatically account for DST (PatternFormatter)

This commit is contained in:
Guenter Obiltschnig
2014-10-30 14:06:13 +01:00
parent abfb96877d
commit 721405d1fc
2 changed files with 17 additions and 17 deletions

View File

@@ -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)
{