You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/07/16 11:40:08 UTC

[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #840: MINIFICPP-1293 Fix the failing PropertyTests

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



##########
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:
       Instead of providing `mkgmtime` on posix, I would opt for converting `parseDateTimeStr` to use `strptime` on posix and use the current implementation with a direct call to `_mkgmtime` on windows. This way we can avoid maintaining date/time code, [which is a pain](https://www.youtube.com/watch?v=-5wpm-gesOY).




----------------------------------------------------------------
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:
users@infra.apache.org