fgerlits commented on a change in pull request #867:
URL: https://github.com/apache/nifi-minifi-cpp/pull/867#discussion_r476467202
##########
File path: extensions/windows-event-log/ConsumeWindowsEventLog.h
##########
@@ -138,6 +139,9 @@ class ConsumeWindowsEventLog : public core::Processor
std::mutex onTriggerMutex_;
std::unordered_map<std::string, std::string> xmlPercentageItemsResolutions_;
HMODULE hMsobjsDll_{};
+
+ std::string timezone_name_;
+ std::string timezone_offset_; // Represented as UTC offset in (H)H:MM
format, like +2:00
Review comment:
```suggestion
std::string timezone_offset_; // Represented as UTC offset in (+|-)HH:MM
format, like +02:00
```
##########
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
tzofset << (tzbias >= 0 ? '+' : '-') << std::setfill('0') << std::setw(2)
<< std::abs(tzbias) / 60
<< ":" << std::setfill('0') << std::setw(2) << std::abs(tzbias) % 60;
```
##########
File path: extensions/windows-event-log/ConsumeWindowsEventLog.h
##########
@@ -101,6 +101,7 @@ class ConsumeWindowsEventLog : public core::Processor
protected:
+ void refreshTimeZoneData();
Review comment:
why not private?
----------------------------------------------------------------
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]