harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r627506 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main: java/java/util/TimeZone.java native/luni/unix/helpers.c
Date Wed, 13 Feb 2008 16:13:37 GMT
Author: ayza
Date: Wed Feb 13 08:13:33 2008
New Revision: 627506

URL: http://svn.apache.org/viewvc?rev=627506&view=rev
Log:
Fallback code for time zone autodetection if JVM failed to set user.timezone system property.
See HARMONY-5476.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java?rev=627506&r1=627505&r2=627506&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TimeZone.java Wed
Feb 13 08:13:33 2008
@@ -423,13 +423,13 @@
                 "user.timezone"));
 
         // sometimes DRLVM incorrectly adds "\n" to the end of timezone ID
-        if (zone.contains("\n")) {
+        if (zone != null && zone.contains("\n")) {
             zone = zone.substring(0, zone.indexOf("\n")); 
         }
 
         // if property user.timezone is not set, we call the native method
         // getCustomTimeZone
-        if (zone == null) {
+        if (zone == null || zone.length() == 0) {
             int[] tzinfo = new int[10];
             boolean[] isCustomTimeZone = new boolean[1];
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c?rev=627506&r1=627505&r2=627506&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/helpers.c Wed Feb
13 08:13:33 2008
@@ -174,7 +174,37 @@
 getCustomTimeZoneInfo (JNIEnv * env, jintArray tzinfo,
                        jbooleanArray isCustomTimeZone)
 {
-  return NULL;
+    time_t curTime;
+    struct tm *tmStruct;
+    char tzInfo[9];
+    int h, m;
+
+    time(&curTime);
+    //curTime += 15552000l;
+    tmStruct = localtime(&curTime);
+    // timezone is now set to time zone offset
+    // tmStruct->tm_isdst is set to 1 if DST is in effect
+    strcpy(tzInfo, "GMT");
+    tzInfo[3] = timezone > 0 ? '-' : '+';
+    h = labs(timezone) / 3600;
+    if (tmStruct->tm_isdst) {
+        if (timezone > 0) {
+            h--;
+        } else {
+            h++;
+        }
+    }
+    m = (labs(timezone) % 3600) / 60;
+    tzInfo[4] = h / 10 + '0';
+    tzInfo[5] = h % 10 + '0';
+    tzInfo[6] = m / 10 + '0';
+    tzInfo[7] = m % 10 + '0';
+    tzInfo[8] = 0;
+
+    jboolean fls = JNI_FALSE;
+
+    (*env)->SetBooleanArrayRegion(env, isCustomTimeZone, 0, 1, &fls);
+    return (*env)->NewStringUTF(env, tzInfo);
 }
 
 void



Mime
View raw message