Skip to content

Commit

Permalink
Re-initialize the time struct before each use. This fixes a bug that …
Browse files Browse the repository at this point in the history
…caused there to be some weirdness with DST and hours being off by one.
  • Loading branch information
wankdanker committed Apr 15, 2011
1 parent aa6593f commit 26f3fe2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,10 @@ int Database::EIO_AfterQuery(eio_req *req) {
tuple->Set(String::New((const char *)columns[i].name), Number::New(atof(buf)));
break;
case SQL_DATETIME :
//I am not sure if this is locale-safe or cross database safe, but it works for me on MSSQL
//strptime(buf, "%Y-%m-%d %H:%M:%S", &timeInfo);
//tuple->Set(String::New((const char *)columns[i].name), Date::New(mktime(&timeInfo) * 1000));
//break;
case SQL_TIMESTAMP :
//reset the value of our time struct to all zeros
memset(&timeInfo, 0, sizeof(struct tm));

//I am not sure if this is locale-safe or cross database safe, but it works for me on MSSQL
strptime(buf, "%Y-%m-%d %H:%M:%S", &timeInfo);
tuple->Set(String::New((const char *)columns[i].name), Date::New(mktime(&timeInfo) * 1000));
Expand Down

0 comments on commit 26f3fe2

Please sign in to comment.