Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for dates before Unix Epoch on Windows OS #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/odbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,18 +438,14 @@ Handle<Value> ODBC::GetColumnValue( SQLHSTMT hStmt, Column column,
//return Null();
}
else {
if (strptime((char *) buffer, "%Y-%m-%d %H:%M:%S", &timeInfo)) {
//a negative value means that mktime() should use timezone information
//and system databases to attempt to determine whether DST is in effect
//at the specified time.
timeInfo.tm_isdst = -1;

//return scope.Escape(Date::New(Isolate::GetCurrent(), (double(mktime(&timeInfo)) * 1000));
return scope.Escape(Nan::New<Date>(double(mktime(&timeInfo)) * 1000).ToLocalChecked());
}
else {
return scope.Escape(Nan::New((char *)buffer).ToLocalChecked());
}
char dateStr[64] = "new Date('";
char *endStr = "')";
strcat(dateStr, (char *)buffer);
strcat(dateStr, endStr);
Handle<String> source = String::NewFromUtf8(Isolate::GetCurrent(), dateStr);
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
return scope.Escape(result);
}
#else
struct tm timeInfo = {
Expand Down