fgerlits commented on a change in pull request #867:
URL: https://github.com/apache/nifi-minifi-cpp/pull/867#discussion_r468403837



##########
File path: extensions/windows-event-log/ConsumeWindowsEventLog.cpp
##########
@@ -624,6 +624,24 @@ void 
ConsumeWindowsEventLog::putEventRenderFlowFileToSession(const EventRender&
     const std::string& str_;
   };
 
+  DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
+  auto ret = GetDynamicTimeZoneInformation(&tzinfo);
+  std::wstring tzstr;
+  std::string tzbias;
+  bool dst = false;
+  switch (ret) {
+  case TIME_ZONE_ID_UNKNOWN:
+    logger_->log_error("Failed to get timezone information!");
+    break;
+  case TIME_ZONE_ID_DAYLIGHT:
+    tzstr = std::wstring(tzinfo.DaylightName, 32);
+    dst = true;

Review comment:
       I would put a `// [[fallthrough]];` comment after this line (and remove 
the `//` when we upgrade to c++17)

##########
File path: extensions/windows-event-log/ConsumeWindowsEventLog.cpp
##########
@@ -635,6 +653,8 @@ void 
ConsumeWindowsEventLog::putEventRenderFlowFileToSession(const EventRender&
       }
     }
     session.putAttribute(flowFile, FlowAttributeKey(MIME_TYPE), 
"application/xml");
+    session.putAttribute(flowFile, "Timezone name", 
wel::to_string(tzstr.c_str()));
+    session.putAttribute(flowFile, "Timezone bias", tzbias);

Review comment:
       I would call this "Timezone offset".  I think "bias" and "daylight bias" 
are Microsoft coinages for the two components of the offset, but here we are 
printing their sum.

##########
File path: extensions/windows-event-log/ConsumeWindowsEventLog.cpp
##########
@@ -624,6 +624,24 @@ void 
ConsumeWindowsEventLog::putEventRenderFlowFileToSession(const EventRender&
     const std::string& str_;
   };
 
+  DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
+  auto ret = GetDynamicTimeZoneInformation(&tzinfo);
+  std::wstring tzstr;
+  std::string tzbias;
+  bool dst = false;
+  switch (ret) {
+  case TIME_ZONE_ID_UNKNOWN:
+    logger_->log_error("Failed to get timezone information!");
+    break;
+  case TIME_ZONE_ID_DAYLIGHT:
+    tzstr = std::wstring(tzinfo.DaylightName, 32);
+    dst = true;
+  case TIME_ZONE_ID_STANDARD:
+    tzstr = tzstr.empty() ? std::wstring(tzinfo.StandardName, 32) : tzstr;  // 
Use standard timezome name in case there is no daylight name or in case it's 
not DST
+    tzbias = std::to_string(tzinfo.Bias + (dst ? tzinfo.DaylightBias : 0));

Review comment:
       It may just be a fancy alias for zero, but 
`DYNAMIC_TIME_ZONE_INFORMATION` has a `StandardBias` field.  So this could be 
written nicer (and possibly safer) as `dst ? tzinfo.DaylightBias : 
tzinfo.StandardBias`




----------------------------------------------------------------
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]


Reply via email to