fgerlits commented on a change in pull request #840:
URL: https://github.com/apache/nifi-minifi-cpp/pull/840#discussion_r455754334
##########
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:
In C++20, there will (finally) be some usable date-time parsing
functions; something like
```c++
stringstream stream{"2020-08-01T01:00:00Z"};
utc_time<seconds> date_time;
stream >> parse("%Y-%m-%dT%H:%M:%SZ", date_time);
return date_time.time_since_epoch().count();
```
but I haven't been able to find a compiler which can compile this, yet.
----------------------------------------------------------------
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]