Changeset: 31dec5ac9d0b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=31dec5ac9d0b
Modified Files:
NT/monetdb_config.h.in
clients/mapiclient/mclient.c
clients/odbc/driver/SQLConnect.c
configure.ag
Branch: Dec2011
Log Message:
Use a more portable way of figuring out our current timezone.
This uses the difference between the values of localtime() and gmtime().
diffs (116 lines):
diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -590,9 +590,6 @@
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1
-/* Define to 1 if you have the timezone and daylight variables. */
-#define HAVE_TIMEZONE 1
-
/* Define to 1 if you have the `trunc' function. */
/* #undef HAVE_TRUNC */
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2491,19 +2491,19 @@ doFile(Mapi mid, const char *file, int u
static void
set_timezone(Mapi mid)
{
-#ifdef HAVE_TIMEZONE
-#ifdef _MSC_VER
-#define timezone _timezone
-#endif
char buf[128];
- struct tm *tm;
- time_t t;
+ time_t t, lt, gt;
+ struct tm *tmp;
long tzone;
MapiHdl hdl;
+ /* figure out our current timezone */
t = time(NULL);
- tm = localtime(&t);
- tzone = timezone - 3600 * tm->tm_isdst;
+ tmp = gmtime(&t);
+ gt = mktime(tmp);
+ tmp = localtime(&t);
+ lt = mktime(tmp);
+ tzone = (long) (gt - lt);
if (tzone < 0)
snprintf(buf, sizeof(buf),
"SET TIME ZONE INTERVAL '+%02ld:%02ld' HOUR TO MINUTE",
@@ -2518,9 +2518,6 @@ set_timezone(Mapi mid)
return;
}
mapi_close_handle(hdl);
-#else
- (void) mid;
-#endif
}
static void usage(const char *prog, int xit)
diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -58,19 +58,19 @@
static void
set_timezone(Mapi mid)
{
-#ifdef HAVE_TIMEZONE
-#ifdef _MSC_VER
-#define timezone _timezone
-#define daylight _daylight
-#define tzset _tzset
-#endif
char buf[128];
+ time_t t, lt, gt;
+ struct tm *tmp;
long tzone;
MapiHdl hdl;
- /* timezone and daylight are POSIX-defined variables */
- tzset();
- tzone = timezone - 3600 * daylight;
+ /* figure out our current timezone */
+ t = time(NULL);
+ tmp = gmtime(&t);
+ gt = mktime(tmp);
+ tmp = localtime(&t);
+ lt = mktime(tmp);
+ tzone = (long) (gt - lt);
if (tzone < 0)
snprintf(buf, sizeof(buf),
"SET TIME ZONE INTERVAL '+%02ld:%02ld' HOUR TO MINUTE",
@@ -81,9 +81,6 @@ set_timezone(Mapi mid)
tzone / 3600, (tzone % 3600) / 60);
if ((hdl = mapi_query(mid, buf)) != NULL)
mapi_close_handle(hdl);
-#else
- (void) mid;
-#endif
}
static void
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2536,16 +2536,6 @@ AH_VERBATIM([__attribute__],
#endif
])
-AC_MSG_CHECKING([if you have timezone and daylight variables])
-AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <time.h>]],
- [[printf("%ld %d\n", timezone, daylight);]])],
- AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_TIMEZONE], 1,
- [Define to 1 if you have the timezone and daylight variables.]),
- AC_MSG_RESULT([no]))
-
dnl checks for library functions
case $host in
*-darwin1[[01234]]*)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list