szaszm commented on code in PR #1434:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1434#discussion_r1053418593
##########
extensions/windows-event-log/wel/WindowsEventLog.cpp:
##########
@@ -25,64 +25,67 @@
#include "UnicodeConversion.h"
#include "utils/Deleters.h"
#include "utils/gsl.h"
+#include "UniqueEvtHandle.h"
namespace org::apache::nifi::minifi::wel {
+namespace {
+std::string GetEventTimestampStr(uint64_t event_timestamp) {
+ SYSTEMTIME st;
+ FILETIME ft;
+
+ ft.dwHighDateTime = (DWORD)((event_timestamp >> 32) & 0xFF'FF'FF'FF);
+ ft.dwLowDateTime = (DWORD)(event_timestamp & 0xFF'FF'FF'FF);
+
+ FileTimeToSystemTime(&ft, &st);
+ std::stringstream datestr;
+
+ std::string period = "AM";
+ auto hour = st.wHour;
+ if (hour >= 12 && hour < 24)
+ period = "PM";
+ if (hour > 12)
+ hour -= 12;
+ if (hour == 0)
+ hour = 12;
+ datestr << st.wMonth << "/" << st.wDay << "/" << st.wYear << " " <<
std::setfill('0') << std::setw(2) << hour << ":" << std::setfill('0')
+ << std::setw(2) << st.wMinute << ":" << std::setfill('0') <<
std::setw(2) << st.wSecond << " " << period;
+ return datestr.str();
+}
+} // namespace
Review Comment:
This is awesome, thanks!
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]