From owner-freebsd-java Wed Mar 13 7: 9:42 2002 Delivered-To: freebsd-java@freebsd.org Received: from Millions.Ca (h-207-228-120-32.gen.cadvision.com [207.228.120.32]) by hub.freebsd.org (Postfix) with ESMTP id 146FD37B419 for ; Wed, 13 Mar 2002 07:09:26 -0800 (PST) Received: (from uucp@localhost) by Millions.Ca (8.11.1/8.9.3) id g2DF9PO19563; Wed, 13 Mar 2002 08:09:25 -0700 (MST) (envelope-from stacy@Millions.Ca) Received: from Cedar.Millions.Ca(192.168.64.8) via SMTP by mail-gw-0.millions.ca, id smtpdj19561; Wed Mar 13 08:09:19 2002 Received: from millions.ca (Maple.Millions.Ca [192.168.64.2]) by cedar.millions.ca (8.11.1/8.11.3) with ESMTP id g2DF9Il37370; Wed, 13 Mar 2002 08:09:18 -0700 (MST) (envelope-from stacy@millions.ca) Message-ID: <3C8F6B9E.CA1AADBA@millions.ca> Date: Wed, 13 Mar 2002 08:09:18 -0700 From: Stacy Millions Organization: Millions Consulting Limited X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Timothy Kettering Cc: FreeBSD-Java Subject: Re: Setting the JVM timezone References: Content-Type: multipart/mixed; boundary="------------E8337002D7EF6B1939B27BD6" Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org This is a multi-part message in MIME format. --------------E8337002D7EF6B1939B27BD6 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Timothy Kettering wrote: > > I realized just now that I had not updated to the patchset6, so I > just did that then reran my tests - still seems that the FreeBSD > native jdk is incorrectly seeing the timezone, while the linux-jdk > reports the right timezone. > > $ /usr/local/jdk1.3.1/bin/java TestRun > The TZ is: GMT+06:00 > $ /usr/local/linux-jdk1.3.1/bin/java TestRun > The TZ is: GMT-06:00 That is reproducible by me as well. Note that setting the TZ environment variable works around the problem. TZ="" - date output Wed Mar 13 07:50:22 MST 2002 TZ="" - native 1.3.1-p6 It is: 2002.03.13 at 21:50:23 GMT+07:00 TZ="" - linux 1.3.1 It is: 2002.03.13 at 07:50:24 GMT-07:00 TZ="" - my patched native 1.3.1 It is: 2002.03.13 at 07:50:25 GMT-07:00 TZ="MST7MDT" - date output Wed Mar 13 07:50:25 MST 2002 TZ="MST7MDT" - native 1.3.1-p6 It is: 2002.03.13 at 07:50:26 MST TZ="MST7MDT" - linux 1.3.1 It is: 2002.03.13 at 07:50:27 MST TZ="MST7MDT" - my patched native 1.3.1 It is: 2002.03.13 at 07:50:28 MST I tracked down (what I think is) the problem. In the file .../src/solaris/native/java/util/TimeZone_md.c you will find the following (this is the original unpatched source) /* Note that the time offset direction is opposite. */ if (timezone > 0) { offset = timezone; sign = '-'; } else { offset = -timezone; sign = '+'; } p6 turns it into: /* Note that the time offset direction is opposite. */ #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) struct tm *local_tm; time_t clock = time(NULL); tzset(); local_tm = localtime(&clock); if (local_tm->tm_gmtoff > 0) { offset = (time_t) local_tm->tm_gmtoff; sign = '-'; } else { offset = (time_t) -local_tm->tm_gmtoff; sign = '+'; } #else if (timezone > 0) { offset = timezone; sign = '-'; } else { offset = -timezone; sign = '+'; } #endif all I did was swap the '+' and '-' and the problem went away. (see attached diff file) Please note that I spent all of .5 hours looking at this (and less testing it), so I don't know if this breaks something else. -stacy -- You'll see it's all a show. Keep 'em laughing as you go. Just remember that the last laugh is on you. - Monty Python _The Life Of Brian_ Stacy Millions stacy@millions.ca Millions Consulting Limited --------------E8337002D7EF6B1939B27BD6 Content-Type: text/plain; charset=us-ascii; name="TimeZone.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="TimeZone.diff" *** TimeZone_md.c-p6 Wed Feb 20 07:54:39 2002 --- TimeZone_md.c Tue Mar 12 21:18:37 2002 *************** *** 390,400 **** local_tm = localtime(&clock); if (local_tm->tm_gmtoff > 0) { offset = (time_t) local_tm->tm_gmtoff; ! sign = '-'; } else { offset = (time_t) -local_tm->tm_gmtoff; ! sign = '+'; } #else if (timezone > 0) { --- 390,400 ---- local_tm = localtime(&clock); if (local_tm->tm_gmtoff > 0) { offset = (time_t) local_tm->tm_gmtoff; ! sign = '+'; } else { offset = (time_t) -local_tm->tm_gmtoff; ! sign = '-'; } #else if (timezone > 0) { --------------E8337002D7EF6B1939B27BD6-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message