fgerlits commented on a change in pull request #867:
URL: https://github.com/apache/nifi-minifi-cpp/pull/867#discussion_r476465535
##########
File path: extensions/windows-event-log/ConsumeWindowsEventLog.cpp
##########
@@ -610,6 +612,36 @@ bool ConsumeWindowsEventLog::createEventRender(EVT_HANDLE
hEvent, EventRender& e
return true;
}
+void ConsumeWindowsEventLog::refreshTimeZoneData() {
+ DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
+ auto ret = GetDynamicTimeZoneInformation(&tzinfo);
+ std::wstring tzstr;
+ long tzbias = 0;
+ bool dst = false;
+ switch (ret) {
+ case TIME_ZONE_ID_UNKNOWN:
+ logger_->log_error("Failed to get timezone information!");
+ return; // Don't update members in case we cannot get data
+ case TIME_ZONE_ID_DAYLIGHT:
+ tzstr = tzinfo.DaylightName;
+ dst = true;
+ // [[fallthrough]];
+ case TIME_ZONE_ID_STANDARD:
+ tzstr = tzstr.empty() ? tzinfo.StandardName : tzstr; // Use standard
timezome name in case there is no daylight name or in case it's not DST
+ tzbias = tzinfo.Bias + (dst ? tzinfo.DaylightBias : tzinfo.StandardBias);
+ break;
+ }
+
+ tzbias *= -1; // WinApi specifies UTC = localtime + bias, but we need
offset from UTC
+ std::stringstream tzoffset;
+ tzoffset << ((tzbias > 0) ? "+" : "") << (tzbias / 60) << ":" <<
std::setfill('0') << std::setw(2) << (std::abs(tzbias % 60));
Review comment:
this prints UTC as "0:00" (which is OK, but "+00:00" is more standard)
and UTC-0:30 as "0:30" (which is wrong -- this time zone doesn't really exist,
but still)
```suggestion
tzoffset << (tzbias >= 0 ? '+' : '-') << std::setfill('0') << std::setw(2)
<< std::abs(tzbias) / 60
<< ":" << std::setfill('0') << std::setw(2) << std::abs(tzbias) % 60;
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]