Changed issue 723 bugfix to use timegm(), reverted Oracle tests (which no longer need to be modified) and substituted NULL for nullptr in issue 723 test for earlier C++ compaticbility

This commit is contained in:
Ross Marwood
2020-03-22 17:42:50 +02:00
parent 3a0a9b0be3
commit 2041df3774
3 changed files with 14 additions and 14 deletions
+7 -7
View File
@@ -11,6 +11,10 @@
// Not <ctime> because we also want to get timegm() if available.
#include <time.h>
#ifdef _MSC_VER
#define timegm _mkgmtime
#endif
namespace soci
{
@@ -28,19 +32,15 @@ mktime_from_ymdhms(tm& t,
int year, int month, int day,
int hour, int minute, int second)
{
t.tm_isdst = -1; // DST is unknown
t.tm_wday = -1; // Not set
t.tm_yday = -1; // Not set
t.tm_isdst = -1;
t.tm_year = year - 1900;
t.tm_mon = month - 1;
t.tm_mday = day;
t.tm_hour = hour;
t.tm_min = minute;
t.tm_sec = second;
// There is no normalisation via mktime() due to Daylight Saving Time
// and time zone complications. See issue 723.
timegm(&t);
}
// Helper function for parsing datetime values.
+1 -1
View File
@@ -4071,7 +4071,7 @@ TEST_CASE_METHOD(common_tests, "std::tm timestamp problem with DST", "[core][int
// Store original TZ value so it can be replaced when the test finishes
std::string original_tz_value;
char* tz_value = getenv("TZ");
if (tz_value != nullptr)
if (tz_value != NULL)
{
original_tz_value = tz_value;
}
+6 -6
View File
@@ -38,9 +38,9 @@ TEST_CASE("Oracle datetime", "[oracle][datetime]")
CHECK(t1.tm_mday == t2.tm_mday);
CHECK(t1.tm_mon == t2.tm_mon);
CHECK(t1.tm_year == t2.tm_year);
CHECK(t1.tm_wday == -1); // Not calculated by SOCI, always -1
CHECK(t1.tm_yday == -1); // Not calculated by SOCI, always -1
CHECK(t1.tm_isdst == -1); // DST is unknown
CHECK(t1.tm_wday == t2.tm_wday);
CHECK(t1.tm_yday == t2.tm_yday);
CHECK(t1.tm_isdst == t2.tm_isdst);
// make sure the date is stored properly in Oracle
char buf[25];
@@ -69,9 +69,9 @@ TEST_CASE("Oracle datetime", "[oracle][datetime]")
CHECK(t1.tm_mday == t2.tm_mday);
CHECK(t1.tm_mon == t2.tm_mon);
CHECK(t1.tm_year == t2.tm_year);
CHECK(t1.tm_wday == -1); // Not calculated by SOCI, always -1
CHECK(t1.tm_yday == -1); // Not calculated by SOCI, always -1
CHECK(t1.tm_isdst == -1); // DST is unknown
CHECK(t1.tm_wday == t2.tm_wday);
CHECK(t1.tm_yday == t2.tm_yday);
CHECK(t1.tm_isdst == t2.tm_isdst);
// make sure the date is stored properly in Oracle
char buf[25];