/[classpath]/classpath/native/jni/java-util/java_util_TimeZone.c
ViewVC logotype

Diff of /classpath/native/jni/java-util/java_util_TimeZone.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by mark, Tue Aug 13 21:15:03 2002 UTC revision 1.4 by rupp, Tue Jul 15 07:19:47 2003 UTC
# Line 35  this exception to your version of the li Line 35  this exception to your version of the li
35  obligated to do so.  If you do not wish to do so, delete this  obligated to do so.  If you do not wish to do so, delete this
36  exception statement from your version. */  exception statement from your version. */
37    
38    /* do not move; needed here because of some macro definitions */
39    #include "config.h"
40    
41  #include <stdio.h>  #include <stdio.h>
42  #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  
   
 #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  
43    
44  #include <jni.h>  #include <jni.h>
45    
46  #include "config.h"  #include "target_native.h"
47    #include "target_native_misc.h"
48    
49  #include "java_util_TimeZone.h"  #include "java_util_TimeZone.h"
50    
# Line 70  exception statement from your version. * Line 61  exception statement from your version. *
61  JNIEXPORT jstring JNICALL  JNIEXPORT jstring JNICALL
62  Java_java_util_TimeZone_getDefaultTimeZoneId(JNIEnv *env, jclass clazz)  Java_java_util_TimeZone_getDefaultTimeZoneId(JNIEnv *env, jclass clazz)
63  {  {
64    time_t current_time;  #ifdef HAVE_TZNAME
65    char **tzinfo, *tzid;    char    buffer[128];
66    long tzoffset;    int     result;
67    jstring retval;    jstring retval;
68    
69    current_time = time(0);    TARGET_NATIVE_UTIL_GET_TIMEZONE_STRING(buffer,sizeof(buffer),result);
70    
71    mktime(localtime(&current_time));    retval = (*env)->NewStringUTF(env, buffer);
   tzinfo = tzname;  
   tzoffset = timezone;  
   
   if ((tzoffset % 3600) == 0)  
     tzoffset = tzoffset / 3600;  
   
   if (!strcmp(tzinfo[0], tzinfo[1]))    
     {  
       tzid = (char*)malloc(strlen(tzinfo[0]) + 6);  
       if (!tzid)  
         return(0);  
   
       sprintf(tzid, "%s%ld", tzinfo[0], tzoffset);  
     }  
   else  
     {  
       tzid = (char*)malloc(strlen(tzinfo[0]) + strlen(tzinfo[1]) + 6);  
       if (!tzid)  
         return(0);  
   
       sprintf(tzid, "%s%ld%s", tzinfo[0], tzoffset, tzinfo[1]);  
     }  
   
   retval = (*env)->NewStringUTF(env, tzid);  
   if (!retval)  
     return(0);  
72    
73    return(retval);    return(retval);
74    #else
75      return(0); /* added this statement (crashes without..:-) --Fridi. */
76    #endif /* HAVE_TZNAME */
77  }  }
78    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26