diff options
| author | warrenl <warrenl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-28 03:09:22 +0000 |
|---|---|---|
| committer | warrenl <warrenl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-28 03:09:22 +0000 |
| commit | 1fbe90973cde7a3c75bf3d48a0a533c218a635d3 (patch) | |
| tree | 1662df7a9a7114295c1d93c1195edd57cd72c465 /libjava/java/util/natTimeZone.cc | |
| parent | e878834be90739f89574a37d8303c85207eaefbc (diff) | |
| download | ppe42-gcc-1fbe90973cde7a3c75bf3d48a0a533c218a635d3.tar.gz ppe42-gcc-1fbe90973cde7a3c75bf3d48a0a533c218a635d3.zip | |
* Makefile.am: Added natTimeZone.cc.
* Makefile.in: Rebuilt.
* gnu/gcj/text/LocaleData_en.java: Added DateFormat entries.
* java/text/DateFormatSymbols.java (ampms): Made package private.
(eras): Made package private.
(months): Made package private.
(shortMonths): Made package private.
(shortWeekdays): Made package private.
(weekdays): Made package private.
(formatPrefixes): New private field.
(localPatternCharsDefault): Made private.
(dateFormats): New package private field.
(timeFormats): New package private field.
(formatsForKey): New private method.
(DateFormatSymbols(Locale)): Set dateFormats and timeFormats.
(DateFormatSymbols(DateFormatSymbols)): Ditto.
* java/text/SimpleDateFormat.java: Merged with Classpath.
* java/util/TimeZone.java: Merged with Classpath.
* java/util/natTimeZone.cc: New file.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37808 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util/natTimeZone.cc')
| -rw-r--r-- | libjava/java/util/natTimeZone.cc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/libjava/java/util/natTimeZone.cc b/libjava/java/util/natTimeZone.cc new file mode 100644 index 00000000000..61128c833b6 --- /dev/null +++ b/libjava/java/util/natTimeZone.cc @@ -0,0 +1,72 @@ +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +#include <config.h> + +#include <gcj/cni.h> +#include <java/util/TimeZone.h> + +#include <stdio.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 + +/* + * This method returns a time zone string that is used by the static + * initializer in java.util.TimeZone to create the default timezone + * instance. This is a key into the timezone table used by + * that class. + */ +jstring +java::util::TimeZone::getDefaultTimeZoneId (void) +{ + time_t current_time; + char **tzinfo, *tzid; + long tzoffset; + jstring retval; + + current_time = time(0); + + mktime(localtime(¤t_time)); + tzinfo = tzname; + tzoffset = timezone; + + if ((tzoffset % 3600) == 0) + tzoffset = tzoffset / 3600; + + if (!strcmp(tzinfo[0], tzinfo[1])) + { + tzid = (char*) _Jv_Malloc (strlen(tzinfo[0]) + 6); + if (!tzid) + return NULL; + + sprintf(tzid, "%s%ld", tzinfo[0], tzoffset); + } + else + { + tzid = (char*) _Jv_Malloc (strlen(tzinfo[0]) + strlen(tzinfo[1]) + 6); + if (!tzid) + return NULL; + + sprintf(tzid, "%s%ld%s", tzinfo[0], tzoffset, tzinfo[1]); + } + + retval = JvNewStringUTF (tzid); + _Jv_Free (tzid); + return retval; +} + |

