Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-hx committed Dec 6, 2024
1 parent 921a487 commit 0aef77a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 6 additions & 4 deletions lib/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3253,15 +3253,17 @@ SF_STATUS STDCALL snowflake_timestamp_get_epoch_seconds(SF_TIMESTAMP *ts,
return SF_STATUS_ERROR_NULL_POINTER;
}

time_t epoch_time_local;
time_t epoch_time;

ts->tm_obj.tm_isdst = -1;
epoch_time_local = (time_t) mktime(&ts->tm_obj);
// mktime takes into account tm_gmtoff which is a Linux and OS X ONLY field
#if defined(__linux__) || defined(__APPLE__)
epoch_time_local += ts->tm_obj.tm_gmtoff;
epoch_time = (time_t)mktime(&ts->tm_obj);
epoch_time += ts->tm_obj.tm_gmtoff;
#else
epoch_time = _mkgmtime64(&ts->tm_obj);
#endif
*epoch_time_ptr = epoch_time_local - (ts->tzoffset * 60);
*epoch_time_ptr = epoch_time - (ts->tzoffset * 60);

return SF_STATUS_SUCCESS;
}
Expand Down
3 changes: 0 additions & 3 deletions tests/test_column_fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,6 @@ void test_column_as_timestamp_windows_helper(sf_bool use_arrow) {
? "alter session set C_API_QUERY_RESULT_FORMAT=ARROW_FORCE"
: "alter session set C_API_QUERY_RESULT_FORMAT=JSON");

sf_setenv("TZ", "UTC");
sf_tzset();

snowflake_query(sfstmt, "select "
"NULL, "
"to_timestamp_tz('2018-10-10 12:34:56 -7:00'), "
Expand Down

0 comments on commit 0aef77a

Please sign in to comment.