aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarren Levy <warrenl@redhat.com>2001-01-26 21:57:08 +0000
committerWarren Levy <warrenl@gcc.gnu.org>2001-01-26 21:57:08 +0000
commit5bb1db008c77467f06f954152e24c9c071395aad (patch)
treea02b57c458c7362efc95137bb24bcf3ebd2ba1c5
parent0604c1567548cabaa597001f214520f80de20250 (diff)
downloadgcc-5bb1db008c77467f06f954152e24c9c071395aad.zip
gcc-5bb1db008c77467f06f954152e24c9c071395aad.tar.gz
gcc-5bb1db008c77467f06f954152e24c9c071395aad.tar.bz2
natSystem.cc (getSystemTimeZone): Only use tm_gmtoff and timezone if they are available on the system.
* java/lang/natSystem.cc (getSystemTimeZone): Only use tm_gmtoff and timezone if they are available on the system. From-SVN: r39283
-rw-r--r--libjava/ChangeLog5
-rw-r--r--libjava/java/lang/natSystem.cc17
2 files changed, 20 insertions, 2 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 3f244b7..7169f86 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,8 @@
+2001-01-26 Warren Levy <warrenl@redhat.com>
+
+ * java/lang/natSystem.cc (getSystemTimeZone): Only use tm_gmtoff
+ and timezone if they are available on the system.
+
2001-01-24 Tom Tromey <tromey@redhat.com>
* java/lang/sf_fabs.c: Use uint32_t, not __uint32_t.
diff --git a/libjava/java/lang/natSystem.cc b/libjava/java/lang/natSystem.cc
index c94ad75..3e96559 100644
--- a/libjava/java/lang/natSystem.cc
+++ b/libjava/java/lang/natSystem.cc
@@ -240,15 +240,28 @@ getpwuid_adaptor(T_passwd * (*getpwuid_r)(T_uid user_id, T_passwd *pwd_r,
jstring
java::lang::System::getSystemTimeZone (void)
{
+ struct tm *tim;
time_t current_time;
char **tzinfo, *tzid;
long tzoffset;
current_time = time(0);
- mktime(localtime(&current_time));
+ mktime(tim = localtime(&current_time));
+#ifdef STRUCT_TM_HAS_GMTOFF
+ tzoffset = -(tim->tm_gmtoff); // tm_gmtoff is secs EAST of UTC.
+#elif HAVE_TIMEZONE
+ tzoffset = timezone; // timezone is secs WEST of UTC.
+#else
+ // FIXME: there must be another global if neither tm_gmtoff nor timezone
+ // is available, esp. if tzname is valid.
+ // Richard Earnshaw <rearnsha@arm.com> has suggested using difftime to
+ // calculate between gmtime and localtime (and accounting for possible
+ // daylight savings time) as an alternative. Also note that this same
+ // issue exists in java/util/natGregorianCalendar.cc.
+ tzoffset = 0L;
+#endif
tzinfo = tzname;
- tzoffset = timezone;
if ((tzoffset % 3600) == 0)
tzoffset = tzoffset / 3600;