You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Ferenc Gerlits (Jira)" <ji...@apache.org> on 2020/07/14 14:36:00 UTC
[jira] [Updated] (MINIFICPP-1293) PropertyTests fails on Windows in
time zones east of Greenwich
[ https://issues.apache.org/jira/browse/MINIFICPP-1293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ferenc Gerlits updated MINIFICPP-1293:
--------------------------------------
Description:
In the "Test DateTime Conversion" in PropertyTests.cpp, the test
{noformat}
int64_t timestamp = 0LL;
REQUIRE(true == org::apache::nifi::minifi::core::Property::StringToDateTime("1970-01-01T00:00:00Z", timestamp));
REQUIRE(0LL == timestamp);
{noformat}
fails, because {{StringToDateTime}} uses {{mktime}} internally to convert a UTC {{stuct tm}} to a localtime {{time_h}}, and then adjust it back to UTC by adding a time zone offset.
"1970-01-01T00:00:00" in local time east of Greenwich results in a negative {{time_h}} value, which is not officially supported by {{mktime}}. On Windows, {{mktime}} returns -1 to signal an error, so the test fails. On Linux, if the time zone is UTC+1, {{mktime}} returns -3600, so the test passes; however, if we were to test "1970-01-01T00:59:59", then {{mktime}} would have to return -1 as the answer, which looks like an error, so this test would fail.
was:
In the "Test DateTime Conversion" in PropertyTests.cpp, the test
{noformat}
int64_t timestamp = 0LL;
REQUIRE(true == org::apache::nifi::minifi::core::Property::StringToDateTime("1970-01-01T00:00:00Z", timestamp));
REQUIRE(0LL == timestamp);
{noformat}
fails, because {{StringToDateTime}} uses {{mktime}} internally to convert a UTC {{stuct tm}} to a localtime {{time_h}}, and then adjust it back to UTC by adding a time zone offset.
"1970-01-01T00:00:00Z" in local time east of Greenwich results in a negative {{time_h}} value, which is not officially supported by {{mktime}}. On Windows, {{mktime}} returns -1 to signal an error, so the test fails. On Linux, if the time zone is UTC+1, {{mktime}} returns -3600, so the test passes; however, if we were to test "1970-01-01T00:59:59Z", then {{mktime}} would have to return -1 as the answer, which looks like an error, so this test would fail.
> PropertyTests fails on Windows in time zones east of Greenwich
> --------------------------------------------------------------
>
> Key: MINIFICPP-1293
> URL: https://issues.apache.org/jira/browse/MINIFICPP-1293
> Project: Apache NiFi MiNiFi C++
> Issue Type: Bug
> Reporter: Ferenc Gerlits
> Assignee: Ferenc Gerlits
> Priority: Minor
> Fix For: 0.8.0
>
>
> In the "Test DateTime Conversion" in PropertyTests.cpp, the test
> {noformat}
> int64_t timestamp = 0LL;
> REQUIRE(true == org::apache::nifi::minifi::core::Property::StringToDateTime("1970-01-01T00:00:00Z", timestamp));
> REQUIRE(0LL == timestamp);
> {noformat}
> fails, because {{StringToDateTime}} uses {{mktime}} internally to convert a UTC {{stuct tm}} to a localtime {{time_h}}, and then adjust it back to UTC by adding a time zone offset.
> "1970-01-01T00:00:00" in local time east of Greenwich results in a negative {{time_h}} value, which is not officially supported by {{mktime}}. On Windows, {{mktime}} returns -1 to signal an error, so the test fails. On Linux, if the time zone is UTC+1, {{mktime}} returns -3600, so the test passes; however, if we were to test "1970-01-01T00:59:59", then {{mktime}} would have to return -1 as the answer, which looks like an error, so this test would fail.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)