Commit a6f5b6f9 by Warren Levy Committed by Warren Levy

natSystem.cc (getSystemTimeZone): Adjust for DST.

	* java/lang/natSystem.cc (getSystemTimeZone): Adjust for DST.
	* java/text/SimpleDateFormat.java
	(indexInArray): Removed private method.
	(processYear): Removed private method.
	(parseLenient): Removed private method.
	(parseLeadingZeros): Removed private method.
	(parseStrict): Removed private method.
	(expect): Added new private method.
	(parse): Reverted to pre-Classpath merge version with minor fixes.
	* java/util/natGregorianCalendar.cc (computeTime): Handle strict
	calendars.

From-SVN: r41456
parent 7471a1f0
2001-04-20 Warren Levy <warrenl@redhat.com>
* java/lang/natSystem.cc (getSystemTimeZone): Adjust for DST.
* java/text/SimpleDateFormat.java
(indexInArray): Removed private method.
(processYear): Removed private method.
(parseLenient): Removed private method.
(parseLeadingZeros): Removed private method.
(parseStrict): Removed private method.
(expect): Added new private method.
(parse): Reverted to pre-Classpath merge version with minor fixes.
* java/util/natGregorianCalendar.cc (computeTime): Handle strict
calendars.
2001-04-12 Bryce McKinlay <bryce@albatross.co.nz>
* java/io/File.java (normalizePath): New private method.
......
......@@ -249,9 +249,11 @@ java::lang::System::getSystemTimeZone (void)
mktime(tim = localtime(&current_time));
#ifdef STRUCT_TM_HAS_GMTOFF
tzoffset = -(tim->tm_gmtoff); // tm_gmtoff is secs EAST of UTC.
// tm_gmtoff is secs EAST of UTC.
tzoffset = -(tim->tm_gmtoff) + tim->tm_isdst * 3600L;
#elif HAVE_TIMEZONE
tzoffset = timezone; // timezone is secs WEST of UTC.
// timezone is secs WEST of UTC.
tzoffset = timezone;
#else
// FIXME: there must be another global if neither tm_gmtoff nor timezone
// is available, esp. if tzname is valid.
......
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
This file is part of libgcj.
......@@ -15,6 +15,7 @@ details. */
#include <gcj/cni.h>
#include <java/util/TimeZone.h>
#include <java/util/GregorianCalendar.h>
#include <java/lang/IllegalArgumentException.h>
#include <time.h>
void
......@@ -27,11 +28,52 @@ java::util::GregorianCalendar::computeTime ()
tim.tm_mday = elements(fields)[DATE];
tim.tm_mon = elements(fields)[MONTH];
tim.tm_year = elements(fields)[YEAR] - 1900;
tim.tm_isdst = 0; // FIXME
tim.tm_isdst = 0;
#ifndef ECOS
// FIXME: None of the standard C library access to the ECOS calendar
// is yet available.
time_t t = mktime (&tim);
if (!isLenient ())
{
// mktime will correct for any time leniencies (e.g. 31-Apr becomes
// 1-May).
// Daylight savings time is a special case since times in hour 23
// will compute to hour 0 of the next day.
if (tim.tm_isdst == 0 || elements(fields)[HOUR_OF_DAY] != 23)
{
if (tim.tm_sec != elements(fields)[SECOND] ||
tim.tm_min != elements(fields)[MINUTE] ||
tim.tm_hour != elements(fields)[HOUR_OF_DAY] +
(tim.tm_isdst > 0 ? 1 : 0) ||
tim.tm_mday != elements(fields)[DATE] ||
tim.tm_mon != elements(fields)[MONTH] ||
tim.tm_year != elements(fields)[YEAR] - 1900)
throw new java::lang::IllegalArgumentException ();
}
else
{
// The easiest thing to do is to temporarily shift the clock
// back from the 23th hour so mktime doesn't cause the extra
// hour for DST to roll the date to the next day.
struct tm tmp_tim;
tmp_tim.tm_sec = elements(fields)[SECOND];
tmp_tim.tm_min = elements(fields)[MINUTE];
tmp_tim.tm_hour = elements(fields)[HOUR_OF_DAY] - 1;
tmp_tim.tm_mday = elements(fields)[DATE];
tmp_tim.tm_mon = elements(fields)[MONTH];
tmp_tim.tm_year = elements(fields)[YEAR] - 1900;
tmp_tim.tm_isdst = 0;
mktime (&tmp_tim);
if (tmp_tim.tm_sec != elements(fields)[SECOND] ||
tmp_tim.tm_min != elements(fields)[MINUTE] ||
tmp_tim.tm_hour != elements(fields)[HOUR_OF_DAY] ||
tmp_tim.tm_mday != elements(fields)[DATE] ||
tmp_tim.tm_mon != elements(fields)[MONTH] ||
tmp_tim.tm_year != elements(fields)[YEAR] - 1900)
throw new java::lang::IllegalArgumentException ();
}
}
#else
time_t t = 0;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment