I'm attaching the timezone patch I promised Petter.  This populates the
user.timezone system property which makes the JDK time handling work
correctly (at least for me).

In addition to the patch, AC_HEADER_TIME and AC_STRUCT_TIMEZONE need to be
added to the configure.in file to make this work.

-- 
Aaron M. Renn ([EMAIL PROTECTED]) http://www.urbanophile.com/arenn/
Index: lib/libnative/java.lang/system.c
===================================================================
RCS file: /cvsroot/hungry/java/japhar/lib/libnative/java.lang/system.c,v
retrieving revision 1.42
diff -u -r1.42 system.c
--- system.c    1999/01/11 15:01:12     1.42
+++ system.c    1999/01/15 01:12:22
@@ -54,6 +54,17 @@
 #  endif
 #endif
 
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
 #define MYLOG "Native"
 
 JNIEXPORT jlong JNICALL
@@ -172,6 +183,7 @@
  * <dt>user.name                       <dd>User account name
  * <dt>user.home                       <dd>User home directory
  * <dt>user.dir                                <dd>User's current working directory
+ * <dt>user.timezone           <dd>The current timezone
  * </dl>
  * It will also define the java.compiler if env(JAVA_COMPILER) is defined
  */
@@ -207,6 +219,8 @@
 #if HAVE_SYS_UTSNAME_H
   struct utsname utsname;
 #endif
+  time_t t;
+  struct tm *tminfo;
 
   JAVARLOG0(MYLOG, 1, "in java_lang_System_initProperties()\n");
 
@@ -297,6 +311,28 @@
   value = (*env)->NewGlobalRef(env, value);
 
   (*env)->CallVoidMethod(env, props, hash_put, key, value);
+
+  /* add the current timezone */
+  key = (*env)->NewStringUTF(env, "user.timezone");
+  value = 0;
+  t = time(0);
+  tminfo = localtime(&t);
+#if HAVE_TM_ZONE
+  value = (*env)->NewStringUTF(env, tminfo->tm_zone);
+#elif defined(HAVE_TZNAME)
+  value = (*env)->NewStringUTF(env, tzname[tm->tm_isdst]);   
+#else
+#warning No known method to determine current timezone!
+#endif
+
+  if (value)
+    {
+      /* these need to be global or they'll be collected when we return. */
+      key = (*env)->NewGlobalRef(env, key);
+      value = (*env)->NewGlobalRef(env, value);
+
+     (*env)->CallVoidMethod(env, props, hash_put, key, value);
+    }
 
 #if HAVE_SYS_UTSNAME_H
   uname(&utsname);

Reply via email to