Changeset: 761203f6742a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=761203f6742a
Modified Files:
NT/monetdb_config.h.in
clients/mapiclient/mclient.c
configure.ag
Branch: Jun2016
Log Message:
Changes to the way we find out the current time zone.
On Windows, there is a function GetDynamicTimeZoneInformation which
returns whether we're in standard of daylight saving time, and also
provides information about the offset to UTC.
On Linux (and presumably other glibc environments), there is a field
tm_gmtoff in the tm struct that gives the current offset to UTC.
diffs (84 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
@@ -187,6 +187,11 @@
/* Define to 1 if you have the `getaddrinfo' function. */
#define HAVE_GETADDRINFO 1
+/* Define to 1 if you have the `GetDynamicTimeZoneInformation' function. */
+#ifdef _MSC_VER
+#define HAVE_GETDYNAMICTIMEZONEINFORMATION 1
+#endif
+
/* Define to 1 if you have the `getexecname' function. */
/* #undef HAVE_GETEXECNAME */
@@ -211,11 +216,6 @@
/* Define to 1 if you have the `gettimeofday' function. */
/* #undef HAVE_GETTIMEOFDAY */
-/* Define to 1 if you have the `_get_timezone' function. */
-#ifdef _MSC_VER
-#define HAVE__GET_TIMEZONE 1
-#endif
-
/* Define if you have the gsl library */
/* #undef HAVE_GSL */
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2849,15 +2849,33 @@ set_timezone(Mapi mid)
MapiHdl hdl;
/* figure out our current timezone */
-#ifdef HAVE__GET_TIMEZONE
- __time64_t ltime, lt, gt;
- struct tm loctime;
+#if defined HAVE_GETDYNAMICTIMEZONEINFORMATION
+ DYNAMIC_TIME_ZONE_INFORMATION tzinf;
- _time64(<ime);
- _localtime64_s(&loctime, <ime);
- lt = _mktime64(&loctime);
- gt = _mkgmtime64(&loctime);
- tzone = (int) (lt - gt);
+ /* documentation says: UTC = localtime + Bias (in minutes),
+ * but experimentation during DST period says, UTC = localtime
+ * + Bias + DaylightBias, and presumably during non DST
+ * period, UTC = localtime + Bias */
+ switch (GetDynamicTimeZoneInformation(&tzinf)) {
+ case TIME_ZONE_ID_STANDARD:
+ case TIME_ZONE_ID_UNKNOWN:
+ tzone = (int) tzinf.Bias * 60;
+ break;
+ case TIME_ZONE_ID_DAYLIGHT:
+ tzone = (int) (tzinf.Bias + tzinf.DaylightBias) * 60;
+ break;
+ default:
+ /* call failed, we don't know the time zone */
+ tzone = 0;
+ break;
+ }
+#elif defined HAVE_STRUCT_TM_TM_ZONE
+ time_t t;
+ struct tm *tmp;
+
+ t = time(NULL);
+ tmp = localtime(&t);
+ tzone = (int) -tmp->tm_gmtoff;
#else
time_t t, lt, gt;
struct tm *tmp;
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -3213,6 +3213,8 @@ if test $mn_cv_have__sys_siglist = yes;
AC_DEFINE(HAVE__SYS_SIGLIST, 1, [Define if you have _sys_siglist])
fi
+AC_STRUCT_TIMEZONE
+
dnl check dependencies (might need more than just SQL)
if test x"$enable_sql" = xyes && test x"$enable_monetdb5" = x"no" ; then
AC_MSG_ERROR([MonetDB/SQL requires MonetDB5${disable_monetdb5:+
$disable_monetdb5}.])
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list