diff options
| author | Hiroshi Inoue | 2017-05-09 04:10:26 +0000 |
|---|---|---|
| committer | Hiroshi Inoue | 2017-05-13 23:50:58 +0000 |
| commit | 81d329790782f506f0eb18d3e741097985c47d4a (patch) | |
| tree | 14145b5a03d8f6f4c574a09065c6ae6b1e588463 /statement.c | |
| parent | 1850423f0adbbbdbeb6f38dcd05f0226d49614b8 (diff) | |
Implement SC_get_localtime() and reduce time()/localtime() calls.
Diffstat (limited to 'statement.c')
| -rw-r--r-- | statement.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/statement.c b/statement.c index 69ee387..05f7c78 100644 --- a/statement.c +++ b/statement.c @@ -1168,6 +1168,8 @@ SC_clear_error(StatementClass *self) res->sqlstate[0] = '\0'; } self->stmt_time = 0; + memset(&self->localtime, 0, sizeof(self->localtime)); + self->localtime.tm_sec = -1; SC_unref_CC_error(self); } @@ -1546,6 +1548,25 @@ SC_get_time(StatementClass *stmt) return stmt->stmt_time; } +struct tm * +SC_get_localtime(StatementClass *stmt) +{ + struct tm * tim; + + if (stmt->localtime.tm_sec < 0) + { + SC_get_time(stmt); +#ifdef HAVE_LOCALTIME_R + tim = localtime_r(&stmt->stmt_time, &(stmt->localtime)); +#else + tim = localtime(&stmt->stmt_time); + stmt->localtime = *tim; +#endif /* HAVE_LOCALTIME_R */ + } + + return &(stmt->localtime); +} + RETCODE SC_fetch(StatementClass *self) { |
