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



##########
File path: libminifi/include/utils/TimeUtil.h
##########
@@ -108,23 +144,9 @@ inline int64_t parseDateTimeStr(const std::string &str) {
   timeinfo.tm_hour = hours;
   timeinfo.tm_min = minutes;
   timeinfo.tm_sec = seconds;
+  timeinfo.tm_isdst = 0;
 
-  /* Get local timezone offset */
-  time_t utc = time(nullptr);
-  struct tm now_tm = *gmtime(&utc); // NOLINT
-  now_tm.tm_isdst = 0;
-  time_t local = mktime(&now_tm);
-  if (local == -1) {
-    return -1;
-  }
-  int64_t timezone_offset = utc - local;
-
-  /* Convert parsed date */
-  time_t time = mktime(&timeinfo);
-  if (time == -1) {
-    return -1;
-  }
-  return time + timezone_offset;
+  return static_cast<int64_t>(mkgmtime(&timeinfo));

Review comment:
       `strptime` is orthogonal to this change, as `strptime` converts `string` 
 -> `struct tm`, and the problem is with the `struct tm` -> UTC `time_t` 
conversion.
   
   Date/time functions are a pain because of time zones, DST, and leap seconds; 
`mkgmtime` (mercifully) does not need to deal with any of these.  The formula 
set by Pope Gregory in 1582 is unlikely to change anytime soon.




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