Blame SOURCES/gcc34-java-zoneinfo.patch

4e62ec
2007-02-24  Jakub Jelinek  <jakub@redhat.com>
4e62ec
4e62ec
	* java/util/TimeZone.java (getDefaultDisplayName): Don't
4e62ec
	check if TimeZone is instanceof SimpleTimeZone.
4e62ec
4e62ec
2007-02-23  Jakub Jelinek  <jakub@redhat.com>
4e62ec
4e62ec
	PR libgcj/17002
4e62ec
	PR classpath/28550
4e62ec
	* java/lang/System.java: Add gnu.java.util.zoneinfo.dir to comments.
4e62ec
	* posix.cc (_Jv_platform_initProperties): Set
4e62ec
	gnu.java.util.zoneinfo.dir.
4e62ec
	* Makefile.am (ordinary_java_source_files): Add
4e62ec
	gnu/java/util/ZoneInfo.java.
4e62ec
	* Makefile.in: Regenerated.
4e62ec
	* java/util/Date.java (parse): Properly parse 09:01:02 as
4e62ec
	hours/minutes/seconds, not as hours/minutes/year.
4e62ec
	* java/util/SimpleTimeZone.java (getOffset): Handle properly
4e62ec
	millis + dstOffset overflowing into the next day.
4e62ec
	* java/util/TimeZone.java (zoneinfo_dir, availableIDs, aliases0): New
4e62ec
	static fields.
4e62ec
	(timezones): Remove synchronized keyword.  Set zoneinfo_dir.
4e62ec
	If non-null, set up aliases0 and don't put anything into
4e62ec
	timezones0.
4e62ec
	(defaultZone): Call getTZEnvVar to try TZ env var.
4e62ec
	Try to read /etc/localtime using ZoneInfo.readTZFile.
4e62ec
	Call getDefaultTimeZone instead of getTimeZone.
4e62ec
	(getDefaultTimeZone, getDateParams, parseTime): New private methods.
4e62ec
	(getTimeZoneInternal): New private method.
4e62ec
	(getTimeZone): Do the custom ID checking first, canonicalize
4e62ec
	ID for custom IDs as required by documentation.  Call
4e62ec
	getTimeZoneInternal to handle the rest.
4e62ec
	(getAvailableIDs(int)): Add locking.  Handle zoneinfo_dir != null.
4e62ec
	(getAvailableIDs(File,String,ArrayList)): New private method.
4e62ec
	(getAvailableIDs()): Add locking.  Handle zoneinfo_dir != null.
4e62ec
	(readSysconfigClockFile): New static method.
4e62ec
	(getTZEnvVar): New native method.
4e62ec
	* java/util/natTimeZone.cc: Include stdlib.h.
4e62ec
	(getTZEnvVar): New method.
4e62ec
	* gnu/java/util/ZoneInfo.java: New file.
4e62ec
	* java/util/GregorianCalendar.java
4e62ec
	(GregorianCalendar): Call clear before set in the constructors that
4e62ec
	don't initialize it to current time.
4e62ec
4e62ec
2007-02-09  Jakub Jelinek  <jakub@redhat.com>
4e62ec
4e62ec
	PR 23566
4e62ec
	* java/util/TimeZone.java (timezones): Regenerate from tzdata2007a.
4e62ec
4e62ec
2005-02-21  Jeroen Frijters  <jeroen@frijters.net>
4e62ec
4e62ec
	* java/util/GregorianCalendar.java
4e62ec
	(GregorianCalendar): Chained constructors to a (new)
4e62ec
	common constructor.
4e62ec
4e62ec
--- libjava/Makefile.am.jj	2006-10-05 00:38:22.000000000 +0200
4e62ec
+++ libjava/Makefile.am	2007-02-23 13:44:59.000000000 +0100
4e62ec
@@ -2382,6 +2382,7 @@ gnu/java/text/SentenceBreakIterator.java
4e62ec
 gnu/java/text/WordBreakIterator.java \
4e62ec
 gnu/java/util/DoubleEnumeration.java \
4e62ec
 gnu/java/util/EmptyEnumeration.java \
4e62ec
+gnu/java/util/ZoneInfo.java \
4e62ec
 gnu/java/util/prefs/MemoryBasedFactory.java \
4e62ec
 gnu/java/util/prefs/NodeReader.java \
4e62ec
 gnu/java/util/prefs/MemoryBasedPreferences.java \
4e62ec
--- libjava/Makefile.in.jj	2006-10-05 00:38:22.000000000 +0200
4e62ec
+++ libjava/Makefile.in	2007-02-23 13:46:07.000000000 +0100
4e62ec
@@ -2073,6 +2073,7 @@ gnu/java/text/SentenceBreakIterator.java
4e62ec
 gnu/java/text/WordBreakIterator.java \
4e62ec
 gnu/java/util/DoubleEnumeration.java \
4e62ec
 gnu/java/util/EmptyEnumeration.java \
4e62ec
+gnu/java/util/ZoneInfo.java \
4e62ec
 gnu/java/util/prefs/MemoryBasedFactory.java \
4e62ec
 gnu/java/util/prefs/NodeReader.java \
4e62ec
 gnu/java/util/prefs/MemoryBasedPreferences.java \
4e62ec
@@ -3331,6 +3332,7 @@ DEP_FILES =  .deps/$(srcdir)/$(CONVERT_D
4e62ec
 .deps/gnu/java/text/WordBreakIterator.P \
4e62ec
 .deps/gnu/java/util/DoubleEnumeration.P \
4e62ec
 .deps/gnu/java/util/EmptyEnumeration.P \
4e62ec
+.deps/gnu/java/util/ZoneInfo.P \
4e62ec
 .deps/gnu/java/util/prefs/FileBasedFactory.P \
4e62ec
 .deps/gnu/java/util/prefs/MemoryBasedFactory.P \
4e62ec
 .deps/gnu/java/util/prefs/MemoryBasedPreferences.P \
4e62ec
--- libjava/java/util/GregorianCalendar.java.jj	2006-10-05 00:38:18.000000000 +0200
4e62ec
+++ libjava/java/util/GregorianCalendar.java	2007-02-23 19:30:20.000000000 +0100
4e62ec
@@ -121,6 +121,13 @@ public class GregorianCalendar extends C
4e62ec
     this(TimeZone.getDefault(), locale);
4e62ec
   }
4e62ec
 
4e62ec
+  private GregorianCalendar(TimeZone zone, Locale locale, boolean unused)
4e62ec
+  {
4e62ec
+    super(zone, locale);
4e62ec
+    ResourceBundle rb = getBundle(locale);
4e62ec
+    gregorianCutover = ((Date) rb.getObject("gregorianCutOver")).getTime();
4e62ec
+  }
4e62ec
+
4e62ec
   /**
4e62ec
    * Constructs a new GregorianCalender representing the current
4e62ec
    * time with the given time zone and the given locale.
4e62ec
@@ -129,9 +136,7 @@ public class GregorianCalendar extends C
4e62ec
    */
4e62ec
   public GregorianCalendar(TimeZone zone, Locale locale)
4e62ec
   {
4e62ec
-    super(zone, locale);
4e62ec
-    ResourceBundle rb = getBundle(locale);
4e62ec
-    gregorianCutover = ((Date) rb.getObject("gregorianCutOver")).getTime();
4e62ec
+    this(zone, locale, false);
4e62ec
     setTimeInMillis(System.currentTimeMillis());
4e62ec
   }
4e62ec
 
4e62ec
@@ -144,7 +149,8 @@ public class GregorianCalendar extends C
4e62ec
    */
4e62ec
   public GregorianCalendar(int year, int month, int day)
4e62ec
   {
4e62ec
-    super();
4e62ec
+    this(TimeZone.getDefault(), Locale.getDefault(), false);
4e62ec
+    clear();
4e62ec
     set(year, month, day);
4e62ec
   }
4e62ec
 
4e62ec
@@ -159,7 +165,8 @@ public class GregorianCalendar extends C
4e62ec
    */
4e62ec
   public GregorianCalendar(int year, int month, int day, int hour, int minute)
4e62ec
   {
4e62ec
-    super();
4e62ec
+    this(TimeZone.getDefault(), Locale.getDefault(), false);
4e62ec
+    clear();
4e62ec
     set(year, month, day, hour, minute);
4e62ec
   }
4e62ec
 
4e62ec
@@ -176,7 +183,8 @@ public class GregorianCalendar extends C
4e62ec
   public GregorianCalendar(int year, int month, int day,
4e62ec
 			   int hour, int minute, int second)
4e62ec
   {
4e62ec
-    super();
4e62ec
+    this(TimeZone.getDefault(), Locale.getDefault(), false);
4e62ec
+    clear();
4e62ec
     set(year, month, day, hour, minute, second);
4e62ec
   }
4e62ec
 
4e62ec
--- libjava/java/util/SimpleTimeZone.java.jj	2006-10-05 00:38:18.000000000 +0200
4e62ec
+++ libjava/java/util/SimpleTimeZone.java	2007-02-23 14:38:01.000000000 +0100
4e62ec
@@ -460,16 +460,34 @@ public class SimpleTimeZone extends Time
4e62ec
     int daylightSavings = 0;
4e62ec
     if (useDaylight && era == GregorianCalendar.AD && year >= startYear)
4e62ec
       {
4e62ec
+	int orig_year = year;
4e62ec
 	// This does only work for Gregorian calendars :-(
4e62ec
 	// This is mainly because setStartYear doesn't take an era.
4e62ec
 
4e62ec
 	boolean afterStart = !isBefore(year, month, day, dayOfWeek, millis,
4e62ec
 				       startMode, startMonth,
4e62ec
 				       startDay, startDayOfWeek, startTime);
4e62ec
+	millis += dstSavings;
4e62ec
+	if (millis >= 24 * 60 * 60 * 1000)
4e62ec
+	  {
4e62ec
+	    millis -= 24 * 60 * 60 * 1000;
4e62ec
+	    dayOfWeek = (dayOfWeek % 7) + 1;
4e62ec
+	    if (++day > getDaysInMonth(month, year))
4e62ec
+	      {
4e62ec
+		day = 1;
4e62ec
+		if (month++ == Calendar.DECEMBER)
4e62ec
+		  {
4e62ec
+		    month = Calendar.JANUARY;
4e62ec
+		    year++;
4e62ec
+		  }
4e62ec
+	      }
4e62ec
+	  }
4e62ec
 	boolean beforeEnd = isBefore(year, month, day, dayOfWeek, millis,
4e62ec
 				     endMode, endMonth,
4e62ec
 				     endDay, endDayOfWeek, endTime);
4e62ec
 
4e62ec
+	if (orig_year != year)
4e62ec
+	  afterStart = false;
4e62ec
 	if (startMonth < endMonth)
4e62ec
 	  {
4e62ec
 	    // use daylight savings, if the date is after the start of
4e62ec
--- libjava/java/util/Date.java.jj	2006-10-05 00:38:18.000000000 +0200
4e62ec
+++ libjava/java/util/Date.java	2007-02-23 14:38:01.000000000 +0100
4e62ec
@@ -411,6 +411,7 @@ public class Date implements Cloneable, 
4e62ec
 	  }
4e62ec
 	else if (firstch >= '0' && firstch <= '9')
4e62ec
 	  {
4e62ec
+	    int lastPunct = -1;
4e62ec
 	    while (tok != null && tok.length() > 0)
4e62ec
 	      {
4e62ec
 		int punctOffset = tok.length();
4e62ec
@@ -448,6 +449,13 @@ public class Date implements Cloneable, 
4e62ec
 		    else
4e62ec
 		      minute = num;
4e62ec
 		  }
4e62ec
+		else if (lastPunct == ':' && hour >= 0 && (minute < 0 || second < 0))
4e62ec
+		  {
4e62ec
+		    if (minute < 0)
4e62ec
+		      minute = num;
4e62ec
+		    else
4e62ec
+		      second = num;
4e62ec
+		  }
4e62ec
 	        else if ((num >= 70
4e62ec
 			  && (punct == ' ' || punct == ','
4e62ec
 			      || punct == '/' || punct < 0))
4e62ec
@@ -486,6 +494,7 @@ public class Date implements Cloneable, 
4e62ec
 		  tok = null;
4e62ec
 		else
4e62ec
 		  tok = tok.substring(punctOffset + 1);
4e62ec
+		lastPunct = punct;
4e62ec
 	      }
4e62ec
 	  }
4e62ec
 	else if (firstch >= 'A' && firstch <= 'Z')
4e62ec
--- libjava/java/util/natTimeZone.cc.jj	2006-10-05 00:38:18.000000000 +0200
4e62ec
+++ libjava/java/util/natTimeZone.cc	2007-02-23 15:14:38.000000000 +0100
4e62ec
@@ -18,6 +18,7 @@ details.  */
4e62ec
 #include <java/lang/Character.h>
4e62ec
 #include <java/lang/Integer.h>
4e62ec
 
4e62ec
+#include <stdlib.h>
4e62ec
 #include <stdio.h>
4e62ec
 
4e62ec
 #if TIME_WITH_SYS_TIME
4e62ec
@@ -168,3 +169,12 @@ java::util::TimeZone::getDefaultTimeZone
4e62ec
   // If all else fails, return null.
4e62ec
   return NULL;
4e62ec
 }
4e62ec
+
4e62ec
+jstring
4e62ec
+java::util::TimeZone::getTZEnvVar ()
4e62ec
+{
4e62ec
+  const char *tzenv = ::getenv ("TZ");
4e62ec
+  if (tzenv == NULL)
4e62ec
+    return NULL;
4e62ec
+  return JvNewStringUTF (tzenv);
4e62ec
+}
4e62ec
--- libjava/java/util/TimeZone.java.jj	2006-10-05 00:38:18.000000000 +0200
4e62ec
+++ libjava/java/util/TimeZone.java	2007-02-23 15:10:51.000000000 +0100
4e62ec
@@ -38,8 +38,15 @@ exception statement from your version. *
4e62ec
 
4e62ec
 
4e62ec
 package java.util;
4e62ec
-import java.text.DateFormatSymbols;
4e62ec
 import gnu.classpath.Configuration;
4e62ec
+import gnu.java.util.ZoneInfo;
4e62ec
+import java.io.BufferedInputStream;
4e62ec
+import java.io.BufferedReader;
4e62ec
+import java.io.File;
4e62ec
+import java.io.FileInputStream;
4e62ec
+import java.io.InputStreamReader;
4e62ec
+import java.io.IOException;
4e62ec
+import java.text.DateFormatSymbols;
4e62ec
 
4e62ec
 /**
4e62ec
  * This class represents a time zone offset and handles daylight savings.
4e62ec
@@ -94,14 +101,72 @@ public abstract class TimeZone implement
4e62ec
 	    System.loadLibrary("javautil");
4e62ec
 	  }
4e62ec
 	String tzid = System.getProperty("user.timezone");
4e62ec
-	
4e62ec
+
4e62ec
+	if (tzid == null)
4e62ec
+	  {
4e62ec
+	    tzid = getTZEnvVar();
4e62ec
+	    if (tzid != null && tzid.equals(""))
4e62ec
+	      tzid = null;
4e62ec
+	  }
4e62ec
+
4e62ec
+	if (tzid == null)
4e62ec
+	  {
4e62ec
+	    TimeZone zone = ZoneInfo.readTZFile((String) null, "/etc/localtime");
4e62ec
+	    if (zone != null)
4e62ec
+	      {
4e62ec
+		// Try to find a more suitable ID for the /etc/localtime
4e62ec
+		// timezone.
4e62ec
+		// Sometimes /etc/localtime is a symlink to some
4e62ec
+		// /usr/share/zoneinfo/ file.
4e62ec
+		String id = null;
4e62ec
+		try
4e62ec
+		  {
4e62ec
+		    id = new File("/etc/localtime").getCanonicalPath();
4e62ec
+		    if (id != null)
4e62ec
+		      {
4e62ec
+			String zoneinfo_dir
4e62ec
+			  = System.getProperty("gnu.java.util.zoneinfo.dir");
4e62ec
+			if (zoneinfo_dir != null)
4e62ec
+			  zoneinfo_dir
4e62ec
+			    = new File(zoneinfo_dir
4e62ec
+				       + File.separatorChar).getCanonicalPath();
4e62ec
+			if (zoneinfo_dir != null && id.startsWith(zoneinfo_dir))
4e62ec
+			  {
4e62ec
+			    int pos = zoneinfo_dir.length();
4e62ec
+			    while (pos < id.length()
4e62ec
+				   && id.charAt(pos) == File.separatorChar)
4e62ec
+			      pos++;
4e62ec
+			    if (pos < id.length())
4e62ec
+			      id = id.substring(pos);
4e62ec
+			    else
4e62ec
+			      id = null;
4e62ec
+			  }
4e62ec
+			else
4e62ec
+			  id = null;
4e62ec
+		      }
4e62ec
+		  }
4e62ec
+		catch (IOException ioe)
4e62ec
+		  {
4e62ec
+		    id = null;
4e62ec
+		  }
4e62ec
+
4e62ec
+		if (id == null)
4e62ec
+		  id = readSysconfigClockFile("/etc/sysconfig/clock");
4e62ec
+
4e62ec
+		if (id != null)
4e62ec
+		  zone.setID(id);
4e62ec
+		defaultZone0 = zone;
4e62ec
+		return defaultZone0;
4e62ec
+	      }
4e62ec
+	  }
4e62ec
+
4e62ec
 	if (tzid == null)
4e62ec
 	  tzid = getDefaultTimeZoneId();
4e62ec
 	
4e62ec
 	if (tzid == null)
4e62ec
 	  tzid = "GMT";
4e62ec
 	
4e62ec
-	defaultZone0 = getTimeZone(tzid);
4e62ec
+	defaultZone0 = getDefaultTimeZone(tzid);
4e62ec
       }
4e62ec
     return defaultZone0; 
4e62ec
   }
4e62ec
@@ -110,18 +175,76 @@ public abstract class TimeZone implement
4e62ec
   private static final long serialVersionUID = 3581463369166924961L;
4e62ec
 
4e62ec
   /**
4e62ec
-   * Hashtable for timezones by ID.  
4e62ec
+   * Flag whether zoneinfo data should be used,
4e62ec
+   * otherwise builtin timezone data will be provided.
4e62ec
+   */
4e62ec
+  private static String zoneinfo_dir;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Cached copy of getAvailableIDs().
4e62ec
+   */
4e62ec
+  private static String[] availableIDs = null;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * JDK 1.1.x compatibility aliases.
4e62ec
+   */
4e62ec
+  private static Hashtable aliases0;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Hashtable for timezones by ID.
4e62ec
    */
4e62ec
   private static Hashtable timezones0;
4e62ec
   /* initialize this static field lazily to overhead if
4e62ec
    * it is not needed: 
4e62ec
    */
4e62ec
-  private static synchronized Hashtable timezones() {
4e62ec
+  private static Hashtable timezones() {
4e62ec
     if (timezones0==null) 
4e62ec
       {
4e62ec
 	Hashtable timezones = new Hashtable();
4e62ec
 	timezones0 = timezones;
4e62ec
 
4e62ec
+	zoneinfo_dir = System.getProperty("gnu.java.util.zoneinfo.dir");
4e62ec
+	if (zoneinfo_dir != null && !new File(zoneinfo_dir).isDirectory())
4e62ec
+	  zoneinfo_dir = null;
4e62ec
+
4e62ec
+	if (zoneinfo_dir != null)
4e62ec
+	  {
4e62ec
+	    aliases0 = new Hashtable();
4e62ec
+
4e62ec
+	    // These deprecated aliases for JDK 1.1.x compatibility
4e62ec
+	    // should take precedence over data files read from
4e62ec
+	    // /usr/share/zoneinfo.
4e62ec
+	    aliases0.put("ACT", "Australia/Darwin");
4e62ec
+	    aliases0.put("AET", "Australia/Sydney");
4e62ec
+	    aliases0.put("AGT", "America/Argentina/Buenos_Aires");
4e62ec
+	    aliases0.put("ART", "Africa/Cairo");
4e62ec
+	    aliases0.put("AST", "America/Juneau");
4e62ec
+	    aliases0.put("BST", "Asia/Colombo");
4e62ec
+	    aliases0.put("CAT", "Africa/Gaborone");
4e62ec
+	    aliases0.put("CNT", "America/St_Johns");
4e62ec
+	    aliases0.put("CST", "CST6CDT");
4e62ec
+	    aliases0.put("CTT", "Asia/Brunei");
4e62ec
+	    aliases0.put("EAT", "Indian/Comoro");
4e62ec
+	    aliases0.put("ECT", "CET");
4e62ec
+	    aliases0.put("EST", "EST5EDT");
4e62ec
+	    aliases0.put("EST5", "EST5EDT");
4e62ec
+	    aliases0.put("IET", "EST5EDT");
4e62ec
+	    aliases0.put("IST", "Asia/Calcutta");
4e62ec
+	    aliases0.put("JST", "Asia/Seoul");
4e62ec
+	    aliases0.put("MIT", "Pacific/Niue");
4e62ec
+	    aliases0.put("MST", "MST7MDT");
4e62ec
+	    aliases0.put("MST7", "MST7MDT");
4e62ec
+	    aliases0.put("NET", "Indian/Mauritius");
4e62ec
+	    aliases0.put("NST", "Pacific/Auckland");
4e62ec
+	    aliases0.put("PLT", "Indian/Kerguelen");
4e62ec
+	    aliases0.put("PNT", "MST7MDT");
4e62ec
+	    aliases0.put("PRT", "America/Anguilla");
4e62ec
+	    aliases0.put("PST", "PST8PDT");
4e62ec
+	    aliases0.put("SST", "Pacific/Ponape");
4e62ec
+	    aliases0.put("VST", "Asia/Bangkok");
4e62ec
+	    return timezones;
4e62ec
+	  }
4e62ec
+
4e62ec
 	TimeZone tz;
4e62ec
 	// Automatically generated by scripts/timezones.pl
4e62ec
 	// XXX - Should we read this data from a file?
4e62ec
@@ -133,8 +256,8 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Pacific/Pago_Pago", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (-10000 * 3600, "America/Adak",
4e62ec
-	   Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
 	timezones0.put("America/Adak", tz);
4e62ec
 	tz = new SimpleTimeZone(-10000 * 3600, "HST");
4e62ec
 	timezones0.put("HST", tz);
4e62ec
@@ -147,8 +270,8 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Pacific/Marquesas", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (-9000 * 3600, "AST",
4e62ec
-	   Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
 	timezones0.put("AST", tz);
4e62ec
 	timezones0.put("America/Anchorage", tz);
4e62ec
 	timezones0.put("America/Juneau", tz);
4e62ec
@@ -157,33 +280,29 @@ public abstract class TimeZone implement
4e62ec
 	tz = new SimpleTimeZone(-9000 * 3600, "Pacific/Gambier");
4e62ec
 	timezones0.put("Pacific/Gambier", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (-8000 * 3600, "PST",
4e62ec
+	  (-8000 * 3600, "America/Tijuana",
4e62ec
 	   Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
 	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	timezones0.put("America/Tijuana", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (-8000 * 3600, "PST",
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
 	timezones0.put("PST", tz);
4e62ec
 	timezones0.put("PST8PDT", tz);
4e62ec
 	timezones0.put("America/Dawson", tz);
4e62ec
 	timezones0.put("America/Los_Angeles", tz);
4e62ec
-	timezones0.put("America/Tijuana", tz);
4e62ec
 	timezones0.put("America/Vancouver", tz);
4e62ec
 	timezones0.put("America/Whitehorse", tz);
4e62ec
 	timezones0.put("US/Pacific-New", tz);
4e62ec
 	tz = new SimpleTimeZone(-8000 * 3600, "Pacific/Pitcairn");
4e62ec
 	timezones0.put("Pacific/Pitcairn", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (-7000 * 3600, "MST",
4e62ec
+	  (-7000 * 3600, "America/Chihuahua",
4e62ec
 	   Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
 	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
-	timezones0.put("MST", tz);
4e62ec
-	timezones0.put("MST7MDT", tz);
4e62ec
-	timezones0.put("America/Boise", tz);
4e62ec
 	timezones0.put("America/Chihuahua", tz);
4e62ec
-	timezones0.put("America/Denver", tz);
4e62ec
-	timezones0.put("America/Edmonton", tz);
4e62ec
-	timezones0.put("America/Inuvik", tz);
4e62ec
 	timezones0.put("America/Mazatlan", tz);
4e62ec
-	timezones0.put("America/Shiprock", tz);
4e62ec
-	timezones0.put("America/Yellowknife", tz);
4e62ec
 	tz = new SimpleTimeZone(-7000 * 3600, "MST7");
4e62ec
 	timezones0.put("MST7", tz);
4e62ec
 	timezones0.put("PNT", tz);
4e62ec
@@ -191,20 +310,26 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("America/Hermosillo", tz);
4e62ec
 	timezones0.put("America/Phoenix", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (-6000 * 3600, "CST",
4e62ec
+	  (-7000 * 3600, "MST",
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	timezones0.put("MST", tz);
4e62ec
+	timezones0.put("MST7MDT", tz);
4e62ec
+	timezones0.put("America/Boise", tz);
4e62ec
+	timezones0.put("America/Cambridge_Bay", tz);
4e62ec
+	timezones0.put("America/Denver", tz);
4e62ec
+	timezones0.put("America/Edmonton", tz);
4e62ec
+	timezones0.put("America/Inuvik", tz);
4e62ec
+	timezones0.put("America/Shiprock", tz);
4e62ec
+	timezones0.put("America/Yellowknife", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (-6000 * 3600, "America/Cancun",
4e62ec
 	   Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
 	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
-	timezones0.put("CST", tz);
4e62ec
-	timezones0.put("CST6CDT", tz);
4e62ec
-	timezones0.put("America/Cambridge_Bay", tz);
4e62ec
 	timezones0.put("America/Cancun", tz);
4e62ec
-	timezones0.put("America/Chicago", tz);
4e62ec
-	timezones0.put("America/Menominee", tz);
4e62ec
 	timezones0.put("America/Merida", tz);
4e62ec
 	timezones0.put("America/Mexico_City", tz);
4e62ec
 	timezones0.put("America/Monterrey", tz);
4e62ec
-	timezones0.put("America/Rainy_River", tz);
4e62ec
-	timezones0.put("America/Winnipeg", tz);
4e62ec
 	tz = new SimpleTimeZone(-6000 * 3600, "America/Belize");
4e62ec
 	timezones0.put("America/Belize", tz);
4e62ec
 	timezones0.put("America/Costa_Rica", tz);
4e62ec
@@ -216,57 +341,81 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("America/Tegucigalpa", tz);
4e62ec
 	timezones0.put("Pacific/Galapagos", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
+	  (-6000 * 3600, "CST",
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	timezones0.put("CST", tz);
4e62ec
+	timezones0.put("CST6CDT", tz);
4e62ec
+	timezones0.put("America/Chicago", tz);
4e62ec
+	timezones0.put("America/Indiana/Knox", tz);
4e62ec
+	timezones0.put("America/Indiana/Petersburg", tz);
4e62ec
+	timezones0.put("America/Indiana/Vincennes", tz);
4e62ec
+	timezones0.put("America/Menominee", tz);
4e62ec
+	timezones0.put("America/North_Dakota/Center", tz);
4e62ec
+	timezones0.put("America/North_Dakota/New_Salem", tz);
4e62ec
+	timezones0.put("America/Rainy_River", tz);
4e62ec
+	timezones0.put("America/Rankin_Inlet", tz);
4e62ec
+	timezones0.put("America/Winnipeg", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
 	  (-6000 * 3600, "Pacific/Easter",
4e62ec
-	   Calendar.OCTOBER, 9, -Calendar.SUNDAY, 0 * 3600,
4e62ec
-	   Calendar.MARCH, 9, -Calendar.SUNDAY, 0 * 3600);
4e62ec
+	   Calendar.OCTOBER, 2, Calendar.SATURDAY, 22000 * 3600,
4e62ec
+	   Calendar.MARCH, 2, Calendar.SATURDAY, 22000 * 3600);
4e62ec
 	timezones0.put("Pacific/Easter", tz);
4e62ec
-	tz = new SimpleTimeZone
4e62ec
-	  (-5000 * 3600, "America/Grand_Turk",
4e62ec
-	   Calendar.APRIL, 1, Calendar.SUNDAY, 0 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
4e62ec
-	timezones0.put("America/Grand_Turk", tz);
4e62ec
-	timezones0.put("America/Havana", tz);
4e62ec
 	tz = new SimpleTimeZone(-5000 * 3600, "EST5");
4e62ec
 	timezones0.put("EST5", tz);
4e62ec
 	timezones0.put("IET", tz);
4e62ec
+	timezones0.put("America/Atikokan", tz);
4e62ec
 	timezones0.put("America/Bogota", tz);
4e62ec
 	timezones0.put("America/Cayman", tz);
4e62ec
 	timezones0.put("America/Eirunepe", tz);
4e62ec
 	timezones0.put("America/Guayaquil", tz);
4e62ec
-	timezones0.put("America/Indiana/Indianapolis", tz);
4e62ec
-	timezones0.put("America/Indiana/Knox", tz);
4e62ec
-	timezones0.put("America/Indiana/Marengo", tz);
4e62ec
-	timezones0.put("America/Indiana/Vevay", tz);
4e62ec
-	timezones0.put("America/Indianapolis", tz);
4e62ec
-	timezones0.put("America/Iqaluit", tz);
4e62ec
 	timezones0.put("America/Jamaica", tz);
4e62ec
 	timezones0.put("America/Lima", tz);
4e62ec
 	timezones0.put("America/Panama", tz);
4e62ec
-	timezones0.put("America/Pangnirtung", tz);
4e62ec
+	timezones0.put("America/Rio_Branco", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (-5000 * 3600, "America/Havana",
4e62ec
+	   Calendar.APRIL, 1, Calendar.SUNDAY, 0 * 3600,
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
4e62ec
+	timezones0.put("America/Havana", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (-5000 * 3600, "America/Grand_Turk",
4e62ec
+	   Calendar.APRIL, 1, Calendar.SUNDAY, 0 * 3600,
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
4e62ec
+	timezones0.put("America/Grand_Turk", tz);
4e62ec
 	timezones0.put("America/Port-au-Prince", tz);
4e62ec
-	timezones0.put("America/Porto_Acre", tz);
4e62ec
-	timezones0.put("America/Rankin_Inlet", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (-5000 * 3600, "EST",
4e62ec
-	   Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
 	timezones0.put("EST", tz);
4e62ec
 	timezones0.put("EST5EDT", tz);
4e62ec
 	timezones0.put("America/Detroit", tz);
4e62ec
+	timezones0.put("America/Indiana/Indianapolis", tz);
4e62ec
+	timezones0.put("America/Indiana/Marengo", tz);
4e62ec
+	timezones0.put("America/Indiana/Vevay", tz);
4e62ec
+	timezones0.put("America/Iqaluit", tz);
4e62ec
 	timezones0.put("America/Kentucky/Louisville", tz);
4e62ec
 	timezones0.put("America/Kentucky/Monticello", tz);
4e62ec
-	timezones0.put("America/Louisville", tz);
4e62ec
 	timezones0.put("America/Montreal", tz);
4e62ec
 	timezones0.put("America/Nassau", tz);
4e62ec
 	timezones0.put("America/New_York", tz);
4e62ec
 	timezones0.put("America/Nipigon", tz);
4e62ec
+	timezones0.put("America/Pangnirtung", tz);
4e62ec
 	timezones0.put("America/Thunder_Bay", tz);
4e62ec
+	timezones0.put("America/Toronto", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (-4000 * 3600, "America/Asuncion",
4e62ec
+	   Calendar.OCTOBER, 3, Calendar.SUNDAY, 0 * 3600,
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 0 * 3600);
4e62ec
+	timezones0.put("America/Asuncion", tz);
4e62ec
 	tz = new SimpleTimeZone(-4000 * 3600, "PRT");
4e62ec
 	timezones0.put("PRT", tz);
4e62ec
 	timezones0.put("America/Anguilla", tz);
4e62ec
 	timezones0.put("America/Antigua", tz);
4e62ec
 	timezones0.put("America/Aruba", tz);
4e62ec
 	timezones0.put("America/Barbados", tz);
4e62ec
+	timezones0.put("America/Blanc-Sablon", tz);
4e62ec
 	timezones0.put("America/Boa_Vista", tz);
4e62ec
 	timezones0.put("America/Caracas", tz);
4e62ec
 	timezones0.put("America/Curacao", tz);
4e62ec
@@ -288,26 +437,23 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("America/St_Vincent", tz);
4e62ec
 	timezones0.put("America/Tortola", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (-4000 * 3600, "America/Asuncion",
4e62ec
-	   Calendar.OCTOBER, 1, Calendar.SUNDAY, 0 * 3600,
4e62ec
+	  (-4000 * 3600, "America/Campo_Grande",
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0 * 3600,
4e62ec
 	   Calendar.FEBRUARY, -1, Calendar.SUNDAY, 0 * 3600);
4e62ec
-	timezones0.put("America/Asuncion", tz);
4e62ec
-	tz = new SimpleTimeZone
4e62ec
-	  (-4000 * 3600, "America/Cuiaba",
4e62ec
-	   Calendar.OCTOBER, 2, Calendar.SUNDAY, 0 * 3600,
4e62ec
-	   Calendar.FEBRUARY, 3, Calendar.SUNDAY, 0 * 3600);
4e62ec
+	timezones0.put("America/Campo_Grande", tz);
4e62ec
 	timezones0.put("America/Cuiaba", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (-4000 * 3600, "America/Goose_Bay",
4e62ec
-	   Calendar.APRIL, 1, Calendar.SUNDAY, 60000,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 60000);
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 60000,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 60000);
4e62ec
 	timezones0.put("America/Goose_Bay", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (-4000 * 3600, "America/Glace_Bay",
4e62ec
-	   Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
 	timezones0.put("America/Glace_Bay", tz);
4e62ec
 	timezones0.put("America/Halifax", tz);
4e62ec
+	timezones0.put("America/Moncton", tz);
4e62ec
 	timezones0.put("America/Thule", tz);
4e62ec
 	timezones0.put("Atlantic/Bermuda", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
@@ -318,58 +464,67 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Antarctica/Palmer", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (-4000 * 3600, "Atlantic/Stanley",
4e62ec
-	   Calendar.SEPTEMBER, 2, Calendar.SUNDAY, 0 * 3600,
4e62ec
-	   Calendar.APRIL, 16, -Calendar.SUNDAY, 0 * 3600);
4e62ec
+	   Calendar.SEPTEMBER, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.APRIL, 3, Calendar.SUNDAY, 2000 * 3600);
4e62ec
 	timezones0.put("Atlantic/Stanley", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (-3500 * 3600, "CNT",
4e62ec
-	   Calendar.APRIL, 1, Calendar.SUNDAY, 60000,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 60000);
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 60000,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 60000);
4e62ec
 	timezones0.put("CNT", tz);
4e62ec
 	timezones0.put("America/St_Johns", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (-3000 * 3600, "America/Araguaina",
4e62ec
-	   Calendar.OCTOBER, 2, Calendar.SUNDAY, 0 * 3600,
4e62ec
-	   Calendar.FEBRUARY, 3, Calendar.SUNDAY, 0 * 3600);
4e62ec
-	timezones0.put("America/Araguaina", tz);
4e62ec
+	  (-3000 * 3600, "America/Godthab",
4e62ec
+	   Calendar.MARCH, 30, -Calendar.SATURDAY, 22000 * 3600,
4e62ec
+	   Calendar.OCTOBER, 30, -Calendar.SATURDAY, 23000 * 3600);
4e62ec
+	timezones0.put("America/Godthab", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (-3000 * 3600, "America/Miquelon",
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	timezones0.put("America/Miquelon", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (-3000 * 3600, "America/Montevideo",
4e62ec
+	   Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	   Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	timezones0.put("America/Montevideo", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (-3000 * 3600, "America/Sao_Paulo",
4e62ec
+	   Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0 * 3600,
4e62ec
+	   Calendar.FEBRUARY, -1, Calendar.SUNDAY, 0 * 3600);
4e62ec
 	timezones0.put("America/Sao_Paulo", tz);
4e62ec
 	tz = new SimpleTimeZone(-3000 * 3600, "AGT");
4e62ec
 	timezones0.put("AGT", tz);
4e62ec
+	timezones0.put("America/Araguaina", tz);
4e62ec
+	timezones0.put("America/Argentina/Buenos_Aires", tz);
4e62ec
+	timezones0.put("America/Argentina/Catamarca", tz);
4e62ec
+	timezones0.put("America/Argentina/Cordoba", tz);
4e62ec
+	timezones0.put("America/Argentina/Jujuy", tz);
4e62ec
+	timezones0.put("America/Argentina/La_Rioja", tz);
4e62ec
+	timezones0.put("America/Argentina/Mendoza", tz);
4e62ec
+	timezones0.put("America/Argentina/Rio_Gallegos", tz);
4e62ec
+	timezones0.put("America/Argentina/San_Juan", tz);
4e62ec
+	timezones0.put("America/Argentina/Tucuman", tz);
4e62ec
+	timezones0.put("America/Argentina/Ushuaia", tz);
4e62ec
+	timezones0.put("America/Bahia", tz);
4e62ec
 	timezones0.put("America/Belem", tz);
4e62ec
-	timezones0.put("America/Buenos_Aires", tz);
4e62ec
-	timezones0.put("America/Catamarca", tz);
4e62ec
 	timezones0.put("America/Cayenne", tz);
4e62ec
-	timezones0.put("America/Cordoba", tz);
4e62ec
 	timezones0.put("America/Fortaleza", tz);
4e62ec
-	timezones0.put("America/Jujuy", tz);
4e62ec
 	timezones0.put("America/Maceio", tz);
4e62ec
-	timezones0.put("America/Mendoza", tz);
4e62ec
-	timezones0.put("America/Montevideo", tz);
4e62ec
 	timezones0.put("America/Paramaribo", tz);
4e62ec
 	timezones0.put("America/Recife", tz);
4e62ec
-	timezones0.put("America/Rosario", tz);
4e62ec
-	tz = new SimpleTimeZone
4e62ec
-	  (-3000 * 3600, "America/Godthab",
4e62ec
-	   Calendar.MARCH, 30, -Calendar.SATURDAY, 22000 * 3600,
4e62ec
-	   Calendar.OCTOBER, 30, -Calendar.SATURDAY, 22000 * 3600);
4e62ec
-	timezones0.put("America/Godthab", tz);
4e62ec
-	tz = new SimpleTimeZone
4e62ec
-	  (-3000 * 3600, "America/Miquelon",
4e62ec
-	   Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
-	timezones0.put("America/Miquelon", tz);
4e62ec
+	timezones0.put("Antarctica/Rothera", tz);
4e62ec
 	tz = new SimpleTimeZone(-2000 * 3600, "America/Noronha");
4e62ec
 	timezones0.put("America/Noronha", tz);
4e62ec
 	timezones0.put("Atlantic/South_Georgia", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (-1000 * 3600, "America/Scoresbysund",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
4e62ec
 	timezones0.put("America/Scoresbysund", tz);
4e62ec
 	timezones0.put("Atlantic/Azores", tz);
4e62ec
 	tz = new SimpleTimeZone(-1000 * 3600, "Atlantic/Cape_Verde");
4e62ec
 	timezones0.put("Atlantic/Cape_Verde", tz);
4e62ec
-	timezones0.put("Atlantic/Jan_Mayen", tz);
4e62ec
 	tz = new SimpleTimeZone(0 * 3600, "GMT");
4e62ec
 	timezones0.put("GMT", tz);
4e62ec
 	timezones0.put("UTC", tz);
4e62ec
@@ -388,21 +543,23 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Africa/Nouakchott", tz);
4e62ec
 	timezones0.put("Africa/Ouagadougou", tz);
4e62ec
 	timezones0.put("Africa/Sao_Tome", tz);
4e62ec
-	timezones0.put("Africa/Timbuktu", tz);
4e62ec
+	timezones0.put("America/Danmarkshavn", tz);
4e62ec
 	timezones0.put("Atlantic/Reykjavik", tz);
4e62ec
 	timezones0.put("Atlantic/St_Helena", tz);
4e62ec
-	timezones0.put("Europe/Belfast", tz);
4e62ec
-	timezones0.put("Europe/Dublin", tz);
4e62ec
-	timezones0.put("Europe/London", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (0 * 3600, "WET",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 1000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
 	timezones0.put("WET", tz);
4e62ec
 	timezones0.put("Atlantic/Canary", tz);
4e62ec
-	timezones0.put("Atlantic/Faeroe", tz);
4e62ec
+	timezones0.put("Atlantic/Faroe", tz);
4e62ec
 	timezones0.put("Atlantic/Madeira", tz);
4e62ec
+	timezones0.put("Europe/Dublin", tz);
4e62ec
+	timezones0.put("Europe/Guernsey", tz);
4e62ec
+	timezones0.put("Europe/Isle_of_Man", tz);
4e62ec
+	timezones0.put("Europe/Jersey", tz);
4e62ec
 	timezones0.put("Europe/Lisbon", tz);
4e62ec
+	timezones0.put("Europe/London", tz);
4e62ec
 	tz = new SimpleTimeZone(1000 * 3600, "Africa/Algiers");
4e62ec
 	timezones0.put("Africa/Algiers", tz);
4e62ec
 	timezones0.put("Africa/Bangui", tz);
4e62ec
@@ -416,7 +573,6 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Africa/Ndjamena", tz);
4e62ec
 	timezones0.put("Africa/Niamey", tz);
4e62ec
 	timezones0.put("Africa/Porto-Novo", tz);
4e62ec
-	timezones0.put("Africa/Tunis", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (1000 * 3600, "Africa/Windhoek",
4e62ec
 	   Calendar.SEPTEMBER, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
@@ -425,12 +581,14 @@ public abstract class TimeZone implement
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (1000 * 3600, "CET",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("CET", tz);
4e62ec
 	timezones0.put("ECT", tz);
4e62ec
 	timezones0.put("MET", tz);
4e62ec
 	timezones0.put("Africa/Ceuta", tz);
4e62ec
+	timezones0.put("Africa/Tunis", tz);
4e62ec
 	timezones0.put("Arctic/Longyearbyen", tz);
4e62ec
+	timezones0.put("Atlantic/Jan_Mayen", tz);
4e62ec
 	timezones0.put("Europe/Amsterdam", tz);
4e62ec
 	timezones0.put("Europe/Andorra", tz);
4e62ec
 	timezones0.put("Europe/Belgrade", tz);
4e62ec
@@ -447,6 +605,7 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Europe/Monaco", tz);
4e62ec
 	timezones0.put("Europe/Oslo", tz);
4e62ec
 	timezones0.put("Europe/Paris", tz);
4e62ec
+	timezones0.put("Europe/Podgorica", tz);
4e62ec
 	timezones0.put("Europe/Prague", tz);
4e62ec
 	timezones0.put("Europe/Rome", tz);
4e62ec
 	timezones0.put("Europe/San_Marino", tz);
4e62ec
@@ -463,7 +622,7 @@ public abstract class TimeZone implement
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (2000 * 3600, "ART",
4e62ec
 	   Calendar.APRIL, -1, Calendar.FRIDAY, 0 * 3600,
4e62ec
-	   Calendar.SEPTEMBER, -1, Calendar.THURSDAY, 23000 * 3600);
4e62ec
+	   Calendar.SEPTEMBER, -1, Calendar.THURSDAY, 24000 * 3600);
4e62ec
 	timezones0.put("ART", tz);
4e62ec
 	timezones0.put("Africa/Cairo", tz);
4e62ec
 	tz = new SimpleTimeZone(2000 * 3600, "CAT");
4e62ec
@@ -480,13 +639,11 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Africa/Maseru", tz);
4e62ec
 	timezones0.put("Africa/Mbabane", tz);
4e62ec
 	timezones0.put("Africa/Tripoli", tz);
4e62ec
-	timezones0.put("Europe/Riga", tz);
4e62ec
-	timezones0.put("Europe/Tallinn", tz);
4e62ec
-	timezones0.put("Europe/Vilnius", tz);
4e62ec
+	timezones0.put("Asia/Jerusalem", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (2000 * 3600, "Asia/Amman",
4e62ec
 	   Calendar.MARCH, -1, Calendar.THURSDAY, 0 * 3600,
4e62ec
-	   Calendar.SEPTEMBER, -1, Calendar.THURSDAY, 0 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.FRIDAY, 1000 * 3600);
4e62ec
 	timezones0.put("Asia/Amman", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (2000 * 3600, "Asia/Beirut",
4e62ec
@@ -500,18 +657,13 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Asia/Damascus", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (2000 * 3600, "Asia/Gaza",
4e62ec
-	   Calendar.APRIL, 3, Calendar.FRIDAY, 0 * 3600,
4e62ec
+	   Calendar.APRIL, 1, 0, 0 * 3600,
4e62ec
 	   Calendar.OCTOBER, 3, Calendar.FRIDAY, 0 * 3600);
4e62ec
 	timezones0.put("Asia/Gaza", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (2000 * 3600, "Asia/Jerusalem",
4e62ec
-	   Calendar.APRIL, 1, 0, 1000 * 3600,
4e62ec
-	   Calendar.OCTOBER, 1, 0, 1000 * 3600);
4e62ec
-	timezones0.put("Asia/Jerusalem", tz);
4e62ec
-	tz = new SimpleTimeZone
4e62ec
 	  (2000 * 3600, "EET",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 4000 * 3600);
4e62ec
 	timezones0.put("EET", tz);
4e62ec
 	timezones0.put("Asia/Istanbul", tz);
4e62ec
 	timezones0.put("Asia/Nicosia", tz);
4e62ec
@@ -521,32 +673,36 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Europe/Helsinki", tz);
4e62ec
 	timezones0.put("Europe/Istanbul", tz);
4e62ec
 	timezones0.put("Europe/Kiev", tz);
4e62ec
+	timezones0.put("Europe/Mariehamn", tz);
4e62ec
 	timezones0.put("Europe/Nicosia", tz);
4e62ec
+	timezones0.put("Europe/Riga", tz);
4e62ec
 	timezones0.put("Europe/Simferopol", tz);
4e62ec
 	timezones0.put("Europe/Sofia", tz);
4e62ec
+	timezones0.put("Europe/Tallinn", tz);
4e62ec
 	timezones0.put("Europe/Uzhgorod", tz);
4e62ec
+	timezones0.put("Europe/Vilnius", tz);
4e62ec
 	timezones0.put("Europe/Zaporozhye", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (2000 * 3600, "Europe/Kaliningrad",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Europe/Kaliningrad", tz);
4e62ec
 	timezones0.put("Europe/Minsk", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (3000 * 3600, "Asia/Baghdad",
4e62ec
 	   Calendar.APRIL, 1, 0, 3000 * 3600,
4e62ec
-	   Calendar.OCTOBER, 1, 0, 3000 * 3600);
4e62ec
+	   Calendar.OCTOBER, 1, 0, 4000 * 3600);
4e62ec
 	timezones0.put("Asia/Baghdad", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (3000 * 3600, "Europe/Moscow",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Europe/Moscow", tz);
4e62ec
-	timezones0.put("Europe/Tiraspol", tz);
4e62ec
+	timezones0.put("Europe/Volgograd", tz);
4e62ec
 	tz = new SimpleTimeZone(3000 * 3600, "EAT");
4e62ec
 	timezones0.put("EAT", tz);
4e62ec
 	timezones0.put("Africa/Addis_Ababa", tz);
4e62ec
-	timezones0.put("Africa/Asmera", tz);
4e62ec
+	timezones0.put("Africa/Asmara", tz);
4e62ec
 	timezones0.put("Africa/Dar_es_Salaam", tz);
4e62ec
 	timezones0.put("Africa/Djibouti", tz);
4e62ec
 	timezones0.put("Africa/Kampala", tz);
4e62ec
@@ -566,75 +722,62 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Asia/Tehran", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (4000 * 3600, "Asia/Baku",
4e62ec
-	   Calendar.MARCH, -1, Calendar.SUNDAY, 1000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
4e62ec
+	   Calendar.MARCH, -1, Calendar.SUNDAY, 4000 * 3600,
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 5000 * 3600);
4e62ec
 	timezones0.put("Asia/Baku", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (4000 * 3600, "Asia/Aqtau",
4e62ec
-	   Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
4e62ec
-	timezones0.put("Asia/Aqtau", tz);
4e62ec
-	timezones0.put("Asia/Tbilisi", tz);
4e62ec
-	tz = new SimpleTimeZone
4e62ec
 	  (4000 * 3600, "Asia/Yerevan",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Asia/Yerevan", tz);
4e62ec
 	timezones0.put("Europe/Samara", tz);
4e62ec
 	tz = new SimpleTimeZone(4000 * 3600, "NET");
4e62ec
 	timezones0.put("NET", tz);
4e62ec
 	timezones0.put("Asia/Dubai", tz);
4e62ec
 	timezones0.put("Asia/Muscat", tz);
4e62ec
+	timezones0.put("Asia/Tbilisi", tz);
4e62ec
 	timezones0.put("Indian/Mahe", tz);
4e62ec
 	timezones0.put("Indian/Mauritius", tz);
4e62ec
 	timezones0.put("Indian/Reunion", tz);
4e62ec
 	tz = new SimpleTimeZone(4500 * 3600, "Asia/Kabul");
4e62ec
 	timezones0.put("Asia/Kabul", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (5000 * 3600, "Asia/Aqtobe",
4e62ec
-	   Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
4e62ec
-	timezones0.put("Asia/Aqtobe", tz);
4e62ec
-	tz = new SimpleTimeZone
4e62ec
-	  (5000 * 3600, "Asia/Bishkek",
4e62ec
-	   Calendar.MARCH, -1, Calendar.SUNDAY, 2500 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2500 * 3600);
4e62ec
-	timezones0.put("Asia/Bishkek", tz);
4e62ec
-	tz = new SimpleTimeZone
4e62ec
 	  (5000 * 3600, "Asia/Yekaterinburg",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Asia/Yekaterinburg", tz);
4e62ec
 	tz = new SimpleTimeZone(5000 * 3600, "PLT");
4e62ec
 	timezones0.put("PLT", tz);
4e62ec
+	timezones0.put("Asia/Aqtau", tz);
4e62ec
+	timezones0.put("Asia/Aqtobe", tz);
4e62ec
 	timezones0.put("Asia/Ashgabat", tz);
4e62ec
 	timezones0.put("Asia/Dushanbe", tz);
4e62ec
 	timezones0.put("Asia/Karachi", tz);
4e62ec
+	timezones0.put("Asia/Oral", tz);
4e62ec
 	timezones0.put("Asia/Samarkand", tz);
4e62ec
 	timezones0.put("Asia/Tashkent", tz);
4e62ec
-	timezones0.put("Indian/Chagos", tz);
4e62ec
 	timezones0.put("Indian/Kerguelen", tz);
4e62ec
 	timezones0.put("Indian/Maldives", tz);
4e62ec
-	tz = new SimpleTimeZone(5500 * 3600, "IST");
4e62ec
+	tz = new SimpleTimeZone(5500 * 3600, "BST");
4e62ec
+	timezones0.put("BST", tz);
4e62ec
 	timezones0.put("IST", tz);
4e62ec
 	timezones0.put("Asia/Calcutta", tz);
4e62ec
+	timezones0.put("Asia/Colombo", tz);
4e62ec
 	tz = new SimpleTimeZone(5750 * 3600, "Asia/Katmandu");
4e62ec
 	timezones0.put("Asia/Katmandu", tz);
4e62ec
-	tz = new SimpleTimeZone(6000 * 3600, "BST");
4e62ec
-	timezones0.put("BST", tz);
4e62ec
+	tz = new SimpleTimeZone(6000 * 3600, "Antarctica/Mawson");
4e62ec
 	timezones0.put("Antarctica/Mawson", tz);
4e62ec
-	timezones0.put("Asia/Colombo", tz);
4e62ec
+	timezones0.put("Antarctica/Vostok", tz);
4e62ec
+	timezones0.put("Asia/Almaty", tz);
4e62ec
+	timezones0.put("Asia/Bishkek", tz);
4e62ec
 	timezones0.put("Asia/Dhaka", tz);
4e62ec
+	timezones0.put("Asia/Qyzylorda", tz);
4e62ec
 	timezones0.put("Asia/Thimphu", tz);
4e62ec
-	tz = new SimpleTimeZone
4e62ec
-	  (6000 * 3600, "Asia/Almaty",
4e62ec
-	   Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
4e62ec
-	timezones0.put("Asia/Almaty", tz);
4e62ec
+	timezones0.put("Indian/Chagos", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (6000 * 3600, "Asia/Novosibirsk",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Asia/Novosibirsk", tz);
4e62ec
 	timezones0.put("Asia/Omsk", tz);
4e62ec
 	tz = new SimpleTimeZone(6500 * 3600, "Asia/Rangoon");
4e62ec
@@ -644,41 +787,57 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("VST", tz);
4e62ec
 	timezones0.put("Antarctica/Davis", tz);
4e62ec
 	timezones0.put("Asia/Bangkok", tz);
4e62ec
-	timezones0.put("Asia/Hovd", tz);
4e62ec
 	timezones0.put("Asia/Jakarta", tz);
4e62ec
 	timezones0.put("Asia/Phnom_Penh", tz);
4e62ec
+	timezones0.put("Asia/Pontianak", tz);
4e62ec
 	timezones0.put("Asia/Saigon", tz);
4e62ec
 	timezones0.put("Asia/Vientiane", tz);
4e62ec
 	timezones0.put("Indian/Christmas", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
+	  (7000 * 3600, "Asia/Hovd",
4e62ec
+	   Calendar.MARCH, -1, Calendar.SATURDAY, 2000 * 3600,
4e62ec
+	   Calendar.SEPTEMBER, -1, Calendar.SATURDAY, 2000 * 3600);
4e62ec
+	timezones0.put("Asia/Hovd", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
 	  (7000 * 3600, "Asia/Krasnoyarsk",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Asia/Krasnoyarsk", tz);
4e62ec
 	tz = new SimpleTimeZone(8000 * 3600, "CTT");
4e62ec
 	timezones0.put("CTT", tz);
4e62ec
 	timezones0.put("Antarctica/Casey", tz);
4e62ec
 	timezones0.put("Asia/Brunei", tz);
4e62ec
-	timezones0.put("Asia/Chungking", tz);
4e62ec
+	timezones0.put("Asia/Chongqing", tz);
4e62ec
 	timezones0.put("Asia/Harbin", tz);
4e62ec
 	timezones0.put("Asia/Hong_Kong", tz);
4e62ec
 	timezones0.put("Asia/Kashgar", tz);
4e62ec
 	timezones0.put("Asia/Kuala_Lumpur", tz);
4e62ec
 	timezones0.put("Asia/Kuching", tz);
4e62ec
-	timezones0.put("Asia/Macao", tz);
4e62ec
+	timezones0.put("Asia/Macau", tz);
4e62ec
+	timezones0.put("Asia/Makassar", tz);
4e62ec
 	timezones0.put("Asia/Manila", tz);
4e62ec
 	timezones0.put("Asia/Shanghai", tz);
4e62ec
 	timezones0.put("Asia/Singapore", tz);
4e62ec
 	timezones0.put("Asia/Taipei", tz);
4e62ec
-	timezones0.put("Asia/Ujung_Pandang", tz);
4e62ec
-	timezones0.put("Asia/Ulaanbaatar", tz);
4e62ec
 	timezones0.put("Asia/Urumqi", tz);
4e62ec
 	timezones0.put("Australia/Perth", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (8000 * 3600, "Asia/Irkutsk",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Asia/Irkutsk", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (8000 * 3600, "Asia/Ulaanbaatar",
4e62ec
+	   Calendar.MARCH, -1, Calendar.SATURDAY, 2000 * 3600,
4e62ec
+	   Calendar.SEPTEMBER, -1, Calendar.SATURDAY, 2000 * 3600);
4e62ec
+	timezones0.put("Asia/Ulaanbaatar", tz);
4e62ec
+	tz = new SimpleTimeZone(8750 * 3600, "Australia/Eucla");
4e62ec
+	timezones0.put("Australia/Eucla", tz);
4e62ec
+	tz = new SimpleTimeZone
4e62ec
+	  (9000 * 3600, "Asia/Choibalsan",
4e62ec
+	   Calendar.MARCH, -1, Calendar.SATURDAY, 2000 * 3600,
4e62ec
+	   Calendar.SEPTEMBER, -1, Calendar.SATURDAY, 2000 * 3600);
4e62ec
+	timezones0.put("Asia/Choibalsan", tz);
4e62ec
 	tz = new SimpleTimeZone(9000 * 3600, "JST");
4e62ec
 	timezones0.put("JST", tz);
4e62ec
 	timezones0.put("Asia/Dili", tz);
4e62ec
@@ -690,12 +849,12 @@ public abstract class TimeZone implement
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (9000 * 3600, "Asia/Yakutsk",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Asia/Yakutsk", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (9500 * 3600, "Australia/Adelaide",
4e62ec
 	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Australia/Adelaide", tz);
4e62ec
 	timezones0.put("Australia/Broken_Hill", tz);
4e62ec
 	tz = new SimpleTimeZone(9500 * 3600, "ACT");
4e62ec
@@ -709,33 +868,34 @@ public abstract class TimeZone implement
4e62ec
 	timezones0.put("Pacific/Port_Moresby", tz);
4e62ec
 	timezones0.put("Pacific/Saipan", tz);
4e62ec
 	timezones0.put("Pacific/Truk", tz);
4e62ec
-	timezones0.put("Pacific/Yap", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (10000 * 3600, "Asia/Vladivostok",
4e62ec
+	  (10000 * 3600, "Asia/Sakhalin",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
+	timezones0.put("Asia/Sakhalin", tz);
4e62ec
 	timezones0.put("Asia/Vladivostok", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
-	  (10000 * 3600, "Australia/Hobart",
4e62ec
+	  (10000 * 3600, "Australia/Currie",
4e62ec
 	   Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
+	timezones0.put("Australia/Currie", tz);
4e62ec
 	timezones0.put("Australia/Hobart", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (10000 * 3600, "AET",
4e62ec
 	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("AET", tz);
4e62ec
 	timezones0.put("Australia/Melbourne", tz);
4e62ec
 	timezones0.put("Australia/Sydney", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (10500 * 3600, "Australia/Lord_Howe",
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600, 500 * 3600);
4e62ec
+	  Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
+	  Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600, 500 * 3600);
4e62ec
 	timezones0.put("Australia/Lord_Howe", tz);
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (11000 * 3600, "Asia/Magadan",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Asia/Magadan", tz);
4e62ec
 	tz = new SimpleTimeZone(11000 * 3600, "SST");
4e62ec
 	timezones0.put("SST", tz);
4e62ec
@@ -749,7 +909,7 @@ public abstract class TimeZone implement
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (12000 * 3600, "NST",
4e62ec
 	   Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.MARCH, 3, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.MARCH, 3, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("NST", tz);
4e62ec
 	timezones0.put("Antarctica/McMurdo", tz);
4e62ec
 	timezones0.put("Antarctica/South_Pole", tz);
4e62ec
@@ -757,7 +917,7 @@ public abstract class TimeZone implement
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (12000 * 3600, "Asia/Anadyr",
4e62ec
 	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
4e62ec
-	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
4e62ec
+	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
4e62ec
 	timezones0.put("Asia/Anadyr", tz);
4e62ec
 	timezones0.put("Asia/Kamchatka", tz);
4e62ec
 	tz = new SimpleTimeZone(12000 * 3600, "Pacific/Fiji");
4e62ec
@@ -772,7 +932,7 @@ public abstract class TimeZone implement
4e62ec
 	tz = new SimpleTimeZone
4e62ec
 	  (12750 * 3600, "Pacific/Chatham",
4e62ec
 	   Calendar.OCTOBER, 1, Calendar.SUNDAY, 2750 * 3600,
4e62ec
-	   Calendar.MARCH, 3, Calendar.SUNDAY, 2750 * 3600);
4e62ec
+	   Calendar.MARCH, 3, Calendar.SUNDAY, 3750 * 3600);
4e62ec
 	timezones0.put("Pacific/Chatham", tz);
4e62ec
 	tz = new SimpleTimeZone(13000 * 3600, "Pacific/Enderbury");
4e62ec
 	timezones0.put("Pacific/Enderbury", tz);
4e62ec
@@ -783,6 +943,342 @@ public abstract class TimeZone implement
4e62ec
     return timezones0;
4e62ec
   }
4e62ec
 
4e62ec
+  /**
4e62ec
+   * Maps a time zone name (with optional GMT offset and daylight time
4e62ec
+   * zone name) to one of the known time zones.  This method called
4e62ec
+   * with the result of System.getProperty("user.timezone")
4e62ec
+   * or getDefaultTimeZoneId().  Note that giving one of
4e62ec
+   * the standard tz data names from ftp://elsie.nci.nih.gov/pub/ is
4e62ec
+   * preferred.  
4e62ec
+   * The time zone name can be given as follows:
4e62ec
+   * (standard zone name)[(GMT offset)[(DST zone name)[DST offset]]]
4e62ec
+   * 
4e62ec
+   * 

4e62ec
+   * If only a (standard zone name) is given (no numbers in the
4e62ec
+   * String) then it gets mapped directly to the TimeZone with that
4e62ec
+   * name, if that fails null is returned.
4e62ec
+   * 

4e62ec
+   * Alternately, a POSIX-style TZ string can be given, defining the time zone:
4e62ec
+   * std offset dst offset,date/time,date/time
4e62ec
+   * See the glibc manual, or the man page for tzset for details
4e62ec
+   * of this format.
4e62ec
+   * 

4e62ec
+   * A GMT offset is the offset to add to the local time to get GMT.
4e62ec
+   * If a (GMT offset) is included (either in seconds or hours) then
4e62ec
+   * an attempt is made to find a TimeZone name matching both the name
4e62ec
+   * and the offset (that doesn't observe daylight time, if the
4e62ec
+   * timezone observes daylight time then you must include a daylight
4e62ec
+   * time zone name after the offset), if that fails then a TimeZone
4e62ec
+   * with the given GMT offset is returned (whether or not the
4e62ec
+   * TimeZone observes daylight time is ignored), if that also fails
4e62ec
+   * the GMT TimeZone is returned.
4e62ec
+   * 

4e62ec
+   * If the String ends with (GMT offset)(daylight time zone name)
4e62ec
+   * then an attempt is made to find a TimeZone with the given name and
4e62ec
+   * GMT offset that also observes (the daylight time zone name is not
4e62ec
+   * currently used in any other way), if that fails a TimeZone with
4e62ec
+   * the given GMT offset that observes daylight time is returned, if
4e62ec
+   * that also fails the GMT TimeZone is returned.
4e62ec
+   * 

4e62ec
+   * Examples: In Chicago, the time zone id could be "CST6CDT", but
4e62ec
+   * the preferred name would be "America/Chicago".  In Indianapolis
4e62ec
+   * (which does not have Daylight Savings Time) the string could be
4e62ec
+   * "EST5", but the preferred name would be "America/Indianapolis".
4e62ec
+   * The standard time zone name for The Netherlands is "Europe/Amsterdam",
4e62ec
+   * but can also be given as "CET-1CEST".
4e62ec
+   */
4e62ec
+  private static TimeZone getDefaultTimeZone(String sysTimeZoneId)
4e62ec
+  {
4e62ec
+    String stdName = null;
4e62ec
+    int stdOffs;
4e62ec
+    int dstOffs;
4e62ec
+    try
4e62ec
+      {
4e62ec
+	int idLength = sysTimeZoneId.length();
4e62ec
+
4e62ec
+	int index = 0;
4e62ec
+	int prevIndex;
4e62ec
+	char c;
4e62ec
+
4e62ec
+	// get std
4e62ec
+	do
4e62ec
+	  c = sysTimeZoneId.charAt(index);
4e62ec
+	while (c != '+' && c != '-' && c != ',' && c != ':'
4e62ec
+	       && ! Character.isDigit(c) && c != '\0' && ++index < idLength);
4e62ec
+
4e62ec
+	if (index >= idLength)
4e62ec
+	  return getTimeZoneInternal(sysTimeZoneId);
4e62ec
+
4e62ec
+	stdName = sysTimeZoneId.substring(0, index);
4e62ec
+	prevIndex = index;
4e62ec
+
4e62ec
+	// get the std offset
4e62ec
+	do
4e62ec
+	  c = sysTimeZoneId.charAt(index++);
4e62ec
+	while ((c == '-' || c == '+' || c == ':' || Character.isDigit(c))
4e62ec
+	       && index < idLength);
4e62ec
+	if (index < idLength)
4e62ec
+	  index--;
4e62ec
+
4e62ec
+	{ // convert the dst string to a millis number
4e62ec
+	    String offset = sysTimeZoneId.substring(prevIndex, index);
4e62ec
+	    prevIndex = index;
4e62ec
+
4e62ec
+	    if (offset.charAt(0) == '+' || offset.charAt(0) == '-')
4e62ec
+	      stdOffs = parseTime(offset.substring(1));
4e62ec
+	    else
4e62ec
+	      stdOffs = parseTime(offset);
4e62ec
+
4e62ec
+	    if (offset.charAt(0) == '-')
4e62ec
+	      stdOffs = -stdOffs;
4e62ec
+
4e62ec
+	    // TZ timezone offsets are positive when WEST of the meridian.
4e62ec
+	    stdOffs = -stdOffs;
4e62ec
+	}
4e62ec
+
4e62ec
+	// Done yet? (Format: std offset)
4e62ec
+	if (index >= idLength)
4e62ec
+	  {
4e62ec
+	    // Do we have an existing timezone with that name and offset?
4e62ec
+	    TimeZone tz = getTimeZoneInternal(stdName);
4e62ec
+	    if (tz != null)
4e62ec
+	      if (tz.getRawOffset() == stdOffs)
4e62ec
+		return tz;
4e62ec
+
4e62ec
+	    // Custom then.
4e62ec
+	    return new SimpleTimeZone(stdOffs, stdName);
4e62ec
+	  }
4e62ec
+
4e62ec
+	// get dst
4e62ec
+	do
4e62ec
+	  c = sysTimeZoneId.charAt(index);
4e62ec
+	while (c != '+' && c != '-' && c != ',' && c != ':'
4e62ec
+	       && ! Character.isDigit(c) && c != '\0' && ++index < idLength);
4e62ec
+
4e62ec
+	// Done yet? (Format: std offset dst)
4e62ec
+	if (index >= idLength)
4e62ec
+	  {
4e62ec
+	    // Do we have an existing timezone with that name and offset
4e62ec
+	    // which has DST?
4e62ec
+	    TimeZone tz = getTimeZoneInternal(stdName);
4e62ec
+	    if (tz != null)
4e62ec
+	      if (tz.getRawOffset() == stdOffs && tz.useDaylightTime())
4e62ec
+		return tz;
4e62ec
+
4e62ec
+	    // Custom then.
4e62ec
+	    return new SimpleTimeZone(stdOffs, stdName);
4e62ec
+	  }
4e62ec
+
4e62ec
+	// get the dst offset
4e62ec
+	prevIndex = index;
4e62ec
+	do
4e62ec
+	  c = sysTimeZoneId.charAt(index++);
4e62ec
+	while ((c == '-' || c == '+' || c == ':' || Character.isDigit(c))
4e62ec
+	       && index < idLength);
4e62ec
+	if (index < idLength)
4e62ec
+	  index--;
4e62ec
+
4e62ec
+	if (index == prevIndex && (c == ',' || c == ';'))
4e62ec
+	  {
4e62ec
+	    // Missing dst offset defaults to one hour ahead of standard
4e62ec
+	    // time.
4e62ec
+	    dstOffs = stdOffs + 60 * 60 * 1000;
4e62ec
+	  }
4e62ec
+	else
4e62ec
+	  { // convert the dst string to a millis number
4e62ec
+	    String offset = sysTimeZoneId.substring(prevIndex, index);
4e62ec
+	    prevIndex = index;
4e62ec
+
4e62ec
+	    if (offset.charAt(0) == '+' || offset.charAt(0) == '-')
4e62ec
+	      dstOffs = parseTime(offset.substring(1));
4e62ec
+	    else
4e62ec
+	      dstOffs = parseTime(offset);
4e62ec
+
4e62ec
+	    if (offset.charAt(0) == '-')
4e62ec
+	      dstOffs = -dstOffs;
4e62ec
+
4e62ec
+	    // TZ timezone offsets are positive when WEST of the meridian.
4e62ec
+	    dstOffs = -dstOffs;
4e62ec
+	  }
4e62ec
+
4e62ec
+	// Done yet? (Format: std offset dst offset)
4e62ec
+	// FIXME: We don't support DST without a rule given. Should we?
4e62ec
+	if (index >= idLength)
4e62ec
+	  {
4e62ec
+	    // Time Zone existing with same name, dst and offsets?
4e62ec
+	    TimeZone tz = getTimeZoneInternal(stdName);
4e62ec
+	    if (tz != null)
4e62ec
+	      if (tz.getRawOffset() == stdOffs && tz.useDaylightTime()
4e62ec
+	          && tz.getDSTSavings() == (dstOffs - stdOffs))
4e62ec
+		return tz;
4e62ec
+
4e62ec
+	    return new SimpleTimeZone(stdOffs, stdName);
4e62ec
+	  }
4e62ec
+
4e62ec
+	// get the DST rule
4e62ec
+	if (sysTimeZoneId.charAt(index) == ','
4e62ec
+	    || sysTimeZoneId.charAt(index) == ';')
4e62ec
+	  {
4e62ec
+	    index++;
4e62ec
+	    int offs = index;
4e62ec
+	    while (sysTimeZoneId.charAt(index) != ','
4e62ec
+	           && sysTimeZoneId.charAt(index) != ';')
4e62ec
+	      index++;
4e62ec
+	    String startTime = sysTimeZoneId.substring(offs, index);
4e62ec
+	    index++;
4e62ec
+	    String endTime = sysTimeZoneId.substring(index);
4e62ec
+
4e62ec
+	    index = startTime.indexOf('/');
4e62ec
+	    int startMillis;
4e62ec
+	    int endMillis;
4e62ec
+	    String startDate;
4e62ec
+	    String endDate;
4e62ec
+	    if (index != -1)
4e62ec
+	      {
4e62ec
+		startDate = startTime.substring(0, index);
4e62ec
+		startMillis = parseTime(startTime.substring(index + 1));
4e62ec
+	      }
4e62ec
+	    else
4e62ec
+	      {
4e62ec
+		startDate = startTime;
4e62ec
+		// if time isn't given, default to 2:00:00 AM.
4e62ec
+		startMillis = 2 * 60 * 60 * 1000;
4e62ec
+	      }
4e62ec
+	    index = endTime.indexOf('/');
4e62ec
+	    if (index != -1)
4e62ec
+	      {
4e62ec
+		endDate = endTime.substring(0, index);
4e62ec
+		endMillis = parseTime(endTime.substring(index + 1));
4e62ec
+	      }
4e62ec
+	    else
4e62ec
+	      {
4e62ec
+		endDate = endTime;
4e62ec
+		// if time isn't given, default to 2:00:00 AM.
4e62ec
+		endMillis = 2 * 60 * 60 * 1000;
4e62ec
+	      }
4e62ec
+
4e62ec
+	    int[] start = getDateParams(startDate);
4e62ec
+	    int[] end = getDateParams(endDate);
4e62ec
+	    return new SimpleTimeZone(stdOffs, stdName, start[0], start[1],
4e62ec
+	                              start[2], startMillis, end[0], end[1],
4e62ec
+	                              end[2], endMillis, (dstOffs - stdOffs));
4e62ec
+	  }
4e62ec
+      }
4e62ec
+
4e62ec
+    // FIXME: Produce a warning here?
4e62ec
+    catch (IndexOutOfBoundsException _)
4e62ec
+      {
4e62ec
+      }
4e62ec
+    catch (NumberFormatException _)
4e62ec
+      {
4e62ec
+      }
4e62ec
+
4e62ec
+    return null;
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Parses and returns the params for a POSIX TZ date field,
4e62ec
+   * in the format int[]{ month, day, dayOfWeek }, following the
4e62ec
+   * SimpleTimeZone constructor rules.
4e62ec
+   */
4e62ec
+  private static int[] getDateParams(String date)
4e62ec
+  {
4e62ec
+    int[] dayCount = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
4e62ec
+    int month;
4e62ec
+
4e62ec
+    if (date.charAt(0) == 'M' || date.charAt(0) == 'm')
4e62ec
+      {
4e62ec
+	int day;
4e62ec
+
4e62ec
+	// Month, week of month, day of week
4e62ec
+
4e62ec
+	// "Mm.w.d".  d is between 0 (Sunday) and 6.  Week w is
4e62ec
+	// between 1 and 5; Week 1 is the first week in which day d
4e62ec
+	// occurs and Week 5 specifies the last d day in the month.
4e62ec
+	// Month m is between 1 and 12.
4e62ec
+
4e62ec
+	month = Integer.parseInt(date.substring(1, date.indexOf('.')));
4e62ec
+	int week = Integer.parseInt(date.substring(date.indexOf('.') + 1,
4e62ec
+	                                           date.lastIndexOf('.')));
4e62ec
+	int dayOfWeek = Integer.parseInt(date.substring(date.lastIndexOf('.')
4e62ec
+	                                                + 1));
4e62ec
+	dayOfWeek++; // Java day of week is one-based, Sunday is first day.
4e62ec
+
4e62ec
+ 	if (week == 5)
4e62ec
+ 	  day = -1; // last day of month is -1 in java, 5 in TZ
4e62ec
+ 	else
4e62ec
+	  {
4e62ec
+	    // First day of week starting on or after.  For example,
4e62ec
+	    // to specify the second Sunday of April, set month to
4e62ec
+	    // APRIL, day-of-month to 8, and day-of-week to -SUNDAY.
4e62ec
+	    day = (week - 1) * 7 + 1;
4e62ec
+	    dayOfWeek = -dayOfWeek;
4e62ec
+	  }
4e62ec
+
4e62ec
+	month--; // Java month is zero-based.
4e62ec
+	return new int[] { month, day, dayOfWeek };
4e62ec
+      }
4e62ec
+
4e62ec
+    // julian day, either zero-based 0<=n<=365 (incl feb 29)
4e62ec
+    // or one-based 1<=n<=365 (no feb 29)
4e62ec
+    int julianDay; // Julian day,
4e62ec
+
4e62ec
+    if (date.charAt(0) != 'J' || date.charAt(0) != 'j')
4e62ec
+      {
4e62ec
+	julianDay = Integer.parseInt(date.substring(1));
4e62ec
+	julianDay++; // make 1-based
4e62ec
+	// Adjust day count to include feb 29.
4e62ec
+	dayCount = new int[]
4e62ec
+	           {
4e62ec
+	             0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335
4e62ec
+	           };
4e62ec
+      }
4e62ec
+    else
4e62ec
+      // 1-based julian day
4e62ec
+      julianDay = Integer.parseInt(date);
4e62ec
+
4e62ec
+    int i = 11;
4e62ec
+    while (i > 0)
4e62ec
+      if (dayCount[i] < julianDay)
4e62ec
+	break;
4e62ec
+      else
4e62ec
+	i--;
4e62ec
+    julianDay -= dayCount[i];
4e62ec
+    month = i;
4e62ec
+    return new int[] { month, julianDay, 0 };
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Parses a time field hh[:mm[:ss]], returning the result
4e62ec
+   * in milliseconds. No leading sign.
4e62ec
+   */
4e62ec
+  private static int parseTime(String time)
4e62ec
+  {
4e62ec
+    int millis = 0;
4e62ec
+    int i = 0;
4e62ec
+
4e62ec
+    while (i < time.length())
4e62ec
+      if (time.charAt(i) == ':')
4e62ec
+	break;
4e62ec
+      else
4e62ec
+	i++;
4e62ec
+    millis = 60 * 60 * 1000 * Integer.parseInt(time.substring(0, i));
4e62ec
+    if (i >= time.length())
4e62ec
+      return millis;
4e62ec
+
4e62ec
+    int iprev = ++i;
4e62ec
+    while (i < time.length())
4e62ec
+      if (time.charAt(i) == ':')
4e62ec
+	break;
4e62ec
+      else
4e62ec
+	i++;
4e62ec
+    millis += 60 * 1000 * Integer.parseInt(time.substring(iprev, i));
4e62ec
+    if (i >= time.length())
4e62ec
+      return millis;
4e62ec
+
4e62ec
+    millis += 1000 * Integer.parseInt(time.substring(++i));
4e62ec
+    return millis;
4e62ec
+  }
4e62ec
 
4e62ec
   /* This method returns us a time zone id string which is in the
4e62ec
      form <standard zone name><GMT offset><daylight time zone name>.
4e62ec
@@ -794,6 +1290,7 @@ public abstract class TimeZone implement
4e62ec
      be EST5
4e62ec
    */
4e62ec
   private static native String getDefaultTimeZoneId();
4e62ec
+  private static native String getTZEnvVar();
4e62ec
 
4e62ec
   /**
4e62ec
    * Gets the time zone offset, for current date, modified in case of 
4e62ec
@@ -955,14 +1452,7 @@ public abstract class TimeZone implement
4e62ec
 
4e62ec
   private String getDefaultDisplayName(boolean dst)
4e62ec
   {
4e62ec
-    int offset = getRawOffset();
4e62ec
-    if (dst && this instanceof SimpleTimeZone)
4e62ec
-      {
4e62ec
-	// ugly, but this is a design failure of the API:
4e62ec
-	// getDisplayName takes a dst parameter even though
4e62ec
-	// TimeZone knows nothing about daylight saving offsets.
4e62ec
-	offset += ((SimpleTimeZone) this).getDSTSavings();
4e62ec
-      }
4e62ec
+    int offset = getRawOffset() + (dst ? getDSTSavings() : 0);
4e62ec
 
4e62ec
     StringBuffer sb = new StringBuffer(9);
4e62ec
     sb.append("GMT");
4e62ec
@@ -1012,30 +1502,67 @@ public abstract class TimeZone implement
4e62ec
    * @return The time zone for the identifier or GMT, if no such time
4e62ec
    * zone exists.
4e62ec
    */
4e62ec
-  // FIXME: XXX: JCL indicates this and other methods are synchronized.
4e62ec
-  public static TimeZone getTimeZone(String ID)
4e62ec
+  private static TimeZone getTimeZoneInternal(String ID)
4e62ec
   {
4e62ec
     // First check timezones hash
4e62ec
-    TimeZone tz = (TimeZone) timezones().get(ID);
4e62ec
-    if (tz != null)
4e62ec
+    TimeZone tz = null;
4e62ec
+    TimeZone tznew = null;
4e62ec
+    for (int pass = 0; pass < 2; pass++)
4e62ec
       {
4e62ec
-	if (tz.getID().equals(ID))
4e62ec
-	  return tz;
4e62ec
+	synchronized (TimeZone.class)
4e62ec
+	  {
4e62ec
+	    tz = (TimeZone) timezones().get(ID);
4e62ec
+	    if (tz != null)
4e62ec
+	      {
4e62ec
+		if (!tz.getID().equals(ID))
4e62ec
+		  {
4e62ec
+		    // We always return a timezone with the requested ID.
4e62ec
+		    // This is the same behaviour as with JDK1.2.
4e62ec
+		    tz = (TimeZone) tz.clone();
4e62ec
+		    tz.setID(ID);
4e62ec
+		    // We also save the alias, so that we return the same
4e62ec
+		    // object again if getTimeZone is called with the same
4e62ec
+		    // alias.
4e62ec
+		    timezones().put(ID, tz);
4e62ec
+		  }
4e62ec
+		return tz;
4e62ec
+	      }
4e62ec
+	    else if (tznew != null)
4e62ec
+	      {
4e62ec
+		timezones().put(ID, tznew);
4e62ec
+		return tznew;
4e62ec
+	      }
4e62ec
+	  }
4e62ec
+
4e62ec
+	if (pass == 1 || zoneinfo_dir == null)
4e62ec
+	  return null;
4e62ec
 
4e62ec
-	// We always return a timezone with the requested ID.
4e62ec
-	// This is the same behaviour as with JDK1.2.
4e62ec
-	tz = (TimeZone) tz.clone();
4e62ec
-	tz.setID(ID);
4e62ec
-	// We also save the alias, so that we return the same
4e62ec
-	// object again if getTimeZone is called with the same
4e62ec
-	// alias.
4e62ec
-	timezones().put(ID, tz);
4e62ec
-	return tz;
4e62ec
+	// aliases0 is never changing after first timezones(), so should
4e62ec
+	// be safe without synchronization.
4e62ec
+	String zonename = (String) aliases0.get(ID);
4e62ec
+	if (zonename == null)
4e62ec
+	  zonename = ID;
4e62ec
+
4e62ec
+	// Read the file outside of the critical section, it is expensive.
4e62ec
+	tznew = ZoneInfo.readTZFile (ID, zoneinfo_dir
4e62ec
+				     + File.separatorChar + zonename);
4e62ec
+	if (tznew == null)
4e62ec
+	  return null;
4e62ec
       }
4e62ec
 
4e62ec
-    // See if the ID is really a GMT offset form.
4e62ec
-    // Note that GMT is in the table so we know it is different.
4e62ec
-    if (ID.startsWith("GMT"))
4e62ec
+    return null;
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Gets the TimeZone for the given ID.
4e62ec
+   * @param ID the time zone identifier.
4e62ec
+   * @return The time zone for the identifier or GMT, if no such time
4e62ec
+   * zone exists.
4e62ec
+   */
4e62ec
+  public static TimeZone getTimeZone(String ID)
4e62ec
+  {
4e62ec
+    // Check for custom IDs first
4e62ec
+    if (ID.startsWith("GMT") && ID.length() > 3)
4e62ec
       {
4e62ec
 	int pos = 3;
4e62ec
 	int offset_direction = 1;
4e62ec
@@ -1080,8 +1607,20 @@ public abstract class TimeZone implement
4e62ec
 		  }
4e62ec
 	      }
4e62ec
 
4e62ec
-	    return new SimpleTimeZone((hour * (60 * 60 * 1000) +
4e62ec
-				       minute * (60 * 1000))
4e62ec
+	    // Custom IDs have to be normalized
4e62ec
+	    StringBuffer sb = new StringBuffer(9);
4e62ec
+	    sb.append("GMT");
4e62ec
+
4e62ec
+	    sb.append(offset_direction >= 0 ? '+' : '-');
4e62ec
+	    sb.append((char) ('0' + hour / 10));
4e62ec
+	    sb.append((char) ('0' + hour % 10));
4e62ec
+	    sb.append(':');
4e62ec
+	    sb.append((char) ('0' + minute / 10));
4e62ec
+	    sb.append((char) ('0' + minute % 10));
4e62ec
+	    ID = sb.toString();
4e62ec
+
4e62ec
+	    return new SimpleTimeZone((hour * (60 * 60 * 1000)
4e62ec
+				       + minute * (60 * 1000))
4e62ec
 				      * offset_direction, ID);
4e62ec
 	  }
4e62ec
 	catch (NumberFormatException e)
4e62ec
@@ -1089,8 +1628,11 @@ public abstract class TimeZone implement
4e62ec
 	  }
4e62ec
       }
4e62ec
 
4e62ec
-    // Finally, return GMT per spec
4e62ec
-    return getTimeZone("GMT");
4e62ec
+    TimeZone tz = getTimeZoneInternal(ID);
4e62ec
+    if (tz != null)
4e62ec
+      return tz;
4e62ec
+
4e62ec
+    return new SimpleTimeZone(0, "GMT");
4e62ec
   }
4e62ec
 
4e62ec
   /**
4e62ec
@@ -1103,37 +1645,134 @@ public abstract class TimeZone implement
4e62ec
    */
4e62ec
   public static String[] getAvailableIDs(int rawOffset)
4e62ec
   {
4e62ec
+    synchronized (TimeZone.class)
4e62ec
+      {
4e62ec
+	Hashtable h = timezones();
4e62ec
+	int count = 0;
4e62ec
+	if (zoneinfo_dir == null)
4e62ec
+	  {
4e62ec
+	    Iterator iter = h.entrySet().iterator();
4e62ec
+	    while (iter.hasNext())
4e62ec
+	      {
4e62ec
+		// Don't iterate the values, since we want to count
4e62ec
+		// doubled values (aliases)
4e62ec
+		Map.Entry entry = (Map.Entry) iter.next();
4e62ec
+		if (((TimeZone) entry.getValue()).getRawOffset() == rawOffset)
4e62ec
+		  count++;
4e62ec
+	      }
4e62ec
+
4e62ec
+	    String[] ids = new String[count];
4e62ec
+	    count = 0;
4e62ec
+	    iter = h.entrySet().iterator();
4e62ec
+	    while (iter.hasNext())
4e62ec
+	      {
4e62ec
+		Map.Entry entry = (Map.Entry) iter.next();
4e62ec
+		if (((TimeZone) entry.getValue()).getRawOffset() == rawOffset)
4e62ec
+		  ids[count++] = (String) entry.getKey();
4e62ec
+	      }
4e62ec
+	    return ids;
4e62ec
+	  }
4e62ec
+      }
4e62ec
+
4e62ec
+    String[] s = getAvailableIDs();
4e62ec
     int count = 0;
4e62ec
-    Iterator iter = timezones().entrySet().iterator();
4e62ec
-    while (iter.hasNext())
4e62ec
+    for (int i = 0; i < s.length; i++)
4e62ec
       {
4e62ec
-	// Don't iterate the values, since we want to count 
4e62ec
-	// doubled values (aliases)
4e62ec
-	Map.Entry entry = (Map.Entry) iter.next();
4e62ec
-	if (((TimeZone) entry.getValue()).getRawOffset() == rawOffset)
4e62ec
+	TimeZone t = getTimeZoneInternal(s[i]);
4e62ec
+	if (t == null || t.getRawOffset() != rawOffset)
4e62ec
+	  s[i] = null;
4e62ec
+	else
4e62ec
 	  count++;
4e62ec
       }
4e62ec
-
4e62ec
     String[] ids = new String[count];
4e62ec
     count = 0;
4e62ec
-    iter = timezones().entrySet().iterator();
4e62ec
-    while (iter.hasNext())
4e62ec
-      {
4e62ec
-	Map.Entry entry = (Map.Entry) iter.next();
4e62ec
-	if (((TimeZone) entry.getValue()).getRawOffset() == rawOffset)
4e62ec
-	  ids[count++] = (String) entry.getKey();
4e62ec
-      }
4e62ec
+    for (int i = 0; i < s.length; i++)
4e62ec
+    if (s[i] != null)
4e62ec
+      ids[count++] = s[i];
4e62ec
+
4e62ec
     return ids;
4e62ec
   }
4e62ec
 
4e62ec
+  private static int getAvailableIDs(File d, String prefix, ArrayList list)
4e62ec
+    {
4e62ec
+      String[] files = d.list();
4e62ec
+      int count = files.length;
4e62ec
+      boolean top = prefix.length() == 0;
4e62ec
+      list.add (files);
4e62ec
+      for (int i = 0; i < files.length; i++)
4e62ec
+	{
4e62ec
+	  if (top
4e62ec
+	      && (files[i].equals("posix")
4e62ec
+		  || files[i].equals("right")
4e62ec
+		  || files[i].endsWith(".tab")
4e62ec
+		  || aliases0.get(files[i]) != null))
4e62ec
+	    {
4e62ec
+	      files[i] = null;
4e62ec
+	      count--;
4e62ec
+	      continue;
4e62ec
+	    }
4e62ec
+
4e62ec
+	  File f = new File(d, files[i]);
4e62ec
+	  if (f.isDirectory())
4e62ec
+	    {
4e62ec
+	      count += getAvailableIDs(f, prefix + files[i]
4e62ec
+				       + File.separatorChar, list) - 1;
4e62ec
+	      files[i] = null;
4e62ec
+	    }
4e62ec
+	  else
4e62ec
+	    files[i] = prefix + files[i];
4e62ec
+	}
4e62ec
+      return count;
4e62ec
+    }
4e62ec
+
4e62ec
   /**
4e62ec
    * Gets all available IDs.
4e62ec
    * @return An array of all supported IDs.
4e62ec
    */
4e62ec
   public static String[] getAvailableIDs()
4e62ec
   {
4e62ec
-    return (String[])
4e62ec
-      timezones().keySet().toArray(new String[timezones().size()]);
4e62ec
+    synchronized (TimeZone.class)
4e62ec
+      {
4e62ec
+	Hashtable h = timezones();
4e62ec
+	if (zoneinfo_dir == null)
4e62ec
+	  return (String[]) h.keySet().toArray(new String[h.size()]);
4e62ec
+
4e62ec
+	if (availableIDs != null)
4e62ec
+	  {
4e62ec
+	    String[] ids = new String[availableIDs.length];
4e62ec
+	    for (int i = 0; i < availableIDs.length; i++)
4e62ec
+	      ids[i] = availableIDs[i];
4e62ec
+	    return ids;
4e62ec
+	  }
4e62ec
+
4e62ec
+	File d = new File(zoneinfo_dir);
4e62ec
+	ArrayList list = new ArrayList(30);
4e62ec
+	int count = getAvailableIDs(d, "", list) + aliases0.size();
4e62ec
+	availableIDs = new String[count];
4e62ec
+	String[] ids = new String[count];
4e62ec
+
4e62ec
+	count = 0;
4e62ec
+	for (int i = 0; i < list.size(); i++)
4e62ec
+	  {
4e62ec
+	    String[] s = (String[]) list.get(i);
4e62ec
+	    for (int j = 0; j < s.length; j++)
4e62ec
+	      if (s[j] != null)
4e62ec
+		{
4e62ec
+		  availableIDs[count] = s[j];
4e62ec
+		  ids[count++] = s[j];
4e62ec
+		}
4e62ec
+	  }
4e62ec
+
4e62ec
+	Iterator iter = aliases0.entrySet().iterator();
4e62ec
+	while (iter.hasNext())
4e62ec
+	  {
4e62ec
+	    Map.Entry entry = (Map.Entry) iter.next();
4e62ec
+	    availableIDs[count] = (String) entry.getKey();
4e62ec
+	    ids[count++] = (String) entry.getKey();
4e62ec
+	  }
4e62ec
+
4e62ec
+	return ids;
4e62ec
+      }
4e62ec
   }
4e62ec
 
4e62ec
   /**
4e62ec
@@ -1179,4 +1818,66 @@ public abstract class TimeZone implement
4e62ec
 	return null;
4e62ec
       }
4e62ec
   }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Tries to read the time zone name from a file.
4e62ec
+   * If the file cannot be read or an IOException occurs null is returned.
4e62ec
+   * 

4e62ec
+   * The /etc/sysconfig/clock file is not standard, but a lot of systems
4e62ec
+   * have it. The file is included by shell scripts and the timezone
4e62ec
+   * name is defined in ZONE variable.
4e62ec
+   * This routine should grok it with or without quotes:
4e62ec
+   * ZONE=America/New_York
4e62ec
+   * or
4e62ec
+   * ZONE="Europe/London"
4e62ec
+   */
4e62ec
+  private static String readSysconfigClockFile(String file)
4e62ec
+  {
4e62ec
+    BufferedReader br = null;
4e62ec
+    try
4e62ec
+      {
4e62ec
+	FileInputStream fis = new FileInputStream(file);
4e62ec
+	BufferedInputStream bis = new BufferedInputStream(fis);
4e62ec
+	br = new BufferedReader(new InputStreamReader(bis));
4e62ec
+
4e62ec
+	for (String line = br.readLine(); line != null; line = br.readLine())
4e62ec
+	  {
4e62ec
+	    line = line.trim();
4e62ec
+	    if (line.length() < 8 || !line.startsWith("ZONE="))
4e62ec
+	      continue;
4e62ec
+	    int posstart = 6;
4e62ec
+	    int posend;
4e62ec
+	    if (line.charAt(5) == '"')
4e62ec
+	      posend = line.indexOf('"', 6);
4e62ec
+	    else if (line.charAt(5) == '\'')
4e62ec
+	      posend = line.indexOf('\'', 6);
4e62ec
+	    else
4e62ec
+	      {
4e62ec
+		posstart = 5;
4e62ec
+		posend = line.length();
4e62ec
+	      }
4e62ec
+	    if (posend < 0)
4e62ec
+	      return null;
4e62ec
+	    return line.substring(posstart, posend);
4e62ec
+	  }
4e62ec
+	return null;
4e62ec
+      }
4e62ec
+    catch (IOException ioe)
4e62ec
+      {
4e62ec
+	// Parse error, not a proper tzfile.
4e62ec
+	return null;
4e62ec
+      }
4e62ec
+    finally
4e62ec
+      {
4e62ec
+	try
4e62ec
+	  {
4e62ec
+	    if (br != null)
4e62ec
+	      br.close();
4e62ec
+	  }
4e62ec
+	catch (IOException ioe)
4e62ec
+	  {
4e62ec
+	    // Error while close, nothing we can do.
4e62ec
+	  }
4e62ec
+      }
4e62ec
+  }
4e62ec
 }
4e62ec
--- libjava/java/lang/System.java.jj	2006-10-05 00:38:03.000000000 +0200
4e62ec
+++ libjava/java/lang/System.java	2007-02-23 14:38:01.000000000 +0100
4e62ec
@@ -355,6 +355,7 @@ public final class System
4e62ec
    * 
gnu.java.io.encoding_scheme_alias.latin?
8859_?
4e62ec
    * 
gnu.java.io.encoding_scheme_alias.UTF-8
UTF8
4e62ec
    * 
gnu.java.io.encoding_scheme_alias.utf-8
UTF8
4e62ec
+   * 
gnu.java.util.zoneinfo.dir
Root of zoneinfo tree
4e62ec
    * 
4e62ec
    *
4e62ec
    * @return the system properties, will never be null
4e62ec
--- libjava/posix.cc.jj	2006-10-05 00:38:22.000000000 +0200
4e62ec
+++ libjava/posix.cc	2007-02-22 23:14:41.000000000 +0100
4e62ec
@@ -102,6 +102,10 @@ _Jv_platform_initProperties (java::util:
4e62ec
   if (! tmpdir)
4e62ec
     tmpdir = "/tmp";
4e62ec
   SET ("java.io.tmpdir", tmpdir);
4e62ec
+  const char *zoneinfodir = ::getenv("TZDATA");
4e62ec
+  if (! zoneinfodir)
4e62ec
+    zoneinfodir = "/usr/share/zoneinfo";
4e62ec
+  SET ("gnu.java.util.zoneinfo.dir", zoneinfodir);
4e62ec
 }
4e62ec
 
4e62ec
 static inline void
4e62ec
--- libjava/gnu/java/util/ZoneInfo.java.jj	2007-02-22 23:14:22.000000000 +0100
4e62ec
+++ libjava/gnu/java/util/ZoneInfo.java	2007-02-23 14:38:01.000000000 +0100
4e62ec
@@ -0,0 +1,1160 @@
4e62ec
+/* gnu.java.util.ZoneInfo
4e62ec
+   Copyright (C) 2007 Free Software Foundation, Inc.
4e62ec
+
4e62ec
+This file is part of GNU Classpath.
4e62ec
+
4e62ec
+GNU Classpath is free software; you can redistribute it and/or modify
4e62ec
+it under the terms of the GNU General Public License as published by
4e62ec
+the Free Software Foundation; either version 2, or (at your option)
4e62ec
+any later version.
4e62ec
+
4e62ec
+GNU Classpath is distributed in the hope that it will be useful, but
4e62ec
+WITHOUT ANY WARRANTY; without even the implied warranty of
4e62ec
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4e62ec
+General Public License for more details.
4e62ec
+
4e62ec
+You should have received a copy of the GNU General Public License
4e62ec
+along with GNU Classpath; see the file COPYING.  If not, write to the
4e62ec
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4e62ec
+02110-1301 USA.
4e62ec
+
4e62ec
+Linking this library statically or dynamically with other modules is
4e62ec
+making a combined work based on this library.  Thus, the terms and
4e62ec
+conditions of the GNU General Public License cover the whole
4e62ec
+combination.
4e62ec
+
4e62ec
+As a special exception, the copyright holders of this library give you
4e62ec
+permission to link this library with independent modules to produce an
4e62ec
+executable, regardless of the license terms of these independent
4e62ec
+modules, and to copy and distribute the resulting executable under
4e62ec
+terms of your choice, provided that you also meet, for each linked
4e62ec
+independent module, the terms and conditions of the license of that
4e62ec
+module.  An independent module is a module which is not derived from
4e62ec
+or based on this library.  If you modify this library, you may extend
4e62ec
+this exception to your version of the library, but you are not
4e62ec
+obligated to do so.  If you do not wish to do so, delete this
4e62ec
+exception statement from your version. */
4e62ec
+
4e62ec
+
4e62ec
+package gnu.java.util;
4e62ec
+
4e62ec
+import java.io.BufferedInputStream;
4e62ec
+import java.io.DataInputStream;
4e62ec
+import java.io.EOFException;
4e62ec
+import java.io.FileInputStream;
4e62ec
+import java.io.InputStream;
4e62ec
+import java.io.IOException;
4e62ec
+import java.util.Calendar;
4e62ec
+import java.util.Date;
4e62ec
+import java.util.GregorianCalendar;
4e62ec
+import java.util.SimpleTimeZone;
4e62ec
+import java.util.TimeZone;
4e62ec
+
4e62ec
+/**
4e62ec
+ * This class represents more advanced variant of java.util.SimpleTimeZone.
4e62ec
+ * It can handle zic(8) compiled transition dates plus uses a SimpleTimeZone
4e62ec
+ * for years beyond last precomputed transition.  Before first precomputed
4e62ec
+ * transition it assumes no daylight saving was in effect.
4e62ec
+ * Timezones that never used daylight saving time should use just
4e62ec
+ * SimpleTimeZone instead of this class.
4e62ec
+ *
4e62ec
+ * This object is tightly bound to the Gregorian calendar.  It assumes
4e62ec
+ * a regular seven days week, and the month lengths are that of the
4e62ec
+ * Gregorian Calendar.
4e62ec
+ *
4e62ec
+ * @see Calendar
4e62ec
+ * @see GregorianCalendar
4e62ec
+ * @see SimpleTimeZone
4e62ec
+ * @author Jakub Jelinek
4e62ec
+ */
4e62ec
+public class ZoneInfo extends TimeZone
4e62ec
+{
4e62ec
+  private static final int SECS_SHIFT = 22;
4e62ec
+  private static final long OFFSET_MASK = (1 << 21) - 1;
4e62ec
+  private static final int OFFSET_SHIFT = 64 - 21;
4e62ec
+  private static final long IS_DST = 1 << 21;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * The raw time zone offset in milliseconds to GMT, ignoring
4e62ec
+   * daylight savings.
4e62ec
+   * @serial
4e62ec
+   */
4e62ec
+  private int rawOffset;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Cached DST savings for the last transition rule.
4e62ec
+   */
4e62ec
+  private int dstSavings;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Cached flag whether last transition rule uses DST saving.
4e62ec
+   */
4e62ec
+  private boolean useDaylight;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Array of encoded transitions.
4e62ec
+   * Transition time in UTC seconds since epoch is in the most
4e62ec
+   * significant 64 - SECS_SHIFT bits, then one bit flag
4e62ec
+   * whether DST is active and the least significant bits
4e62ec
+   * containing offset relative to rawOffset.  Both the DST
4e62ec
+   * flag and relative offset apply to time before the transition
4e62ec
+   * and after or equal to previous transition if any.
4e62ec
+   * The array must be sorted.
4e62ec
+   */
4e62ec
+  private long[] transitions;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * SimpleTimeZone rule which applies on or after the latest
4e62ec
+   * transition.  If the DST changes are not expresible as a
4e62ec
+   * SimpleTimeZone rule, then the rule should just contain
4e62ec
+   * the standard time and no DST time.
4e62ec
+   */
4e62ec
+  private SimpleTimeZone lastRule;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Cached GMT SimpleTimeZone object for internal use in
4e62ec
+   * getOffset method.
4e62ec
+   */
4e62ec
+  private static SimpleTimeZone gmtZone = null;
4e62ec
+
4e62ec
+  static final long serialVersionUID = -3740626706860383657L;
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Create a ZoneInfo with the given time offset
4e62ec
+   * from GMT and with daylight savings.
4e62ec
+   *
4e62ec
+   * @param rawOffset The time offset from GMT in milliseconds.
4e62ec
+   * @param id  The identifier of this time zone.
4e62ec
+   * @param transitions  Array of transition times in UTC seconds since
4e62ec
+   * Epoch in topmost 42 bits, below that 1 boolean bit whether the time
4e62ec
+   * before that transition used daylight saving and in bottommost 21
4e62ec
+   * bits relative daylight saving offset against rawOffset in seconds
4e62ec
+   * that applies before this transition.
4e62ec
+   * @param endRule SimpleTimeZone class describing the daylight saving
4e62ec
+   * rules after the last transition.
4e62ec
+   */
4e62ec
+  public ZoneInfo(int rawOffset, String id, long[] transitions,
4e62ec
+		  SimpleTimeZone lastRule)
4e62ec
+  {
4e62ec
+    if (transitions == null || transitions.length < 1)
4e62ec
+      throw new IllegalArgumentException("transitions must not be null");
4e62ec
+    if (lastRule == null)
4e62ec
+      throw new IllegalArgumentException("lastRule must not be null");
4e62ec
+    this.rawOffset = rawOffset;
4e62ec
+    this.transitions = transitions;
4e62ec
+    this.lastRule = lastRule;
4e62ec
+    setID(id);
4e62ec
+    computeDSTSavings();
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Gets the time zone offset, for current date, modified in case of
4e62ec
+   * daylight savings.  This is the offset to add to UTC to get the local
4e62ec
+   * time.
4e62ec
+   *
4e62ec
+   * The day must be a positive number and dayOfWeek must be a positive value
4e62ec
+   * from Calendar.  dayOfWeek is redundant, but must match the other values
4e62ec
+   * or an inaccurate result may be returned.
4e62ec
+   *
4e62ec
+   * @param era the era of the given date
4e62ec
+   * @param year the year of the given date
4e62ec
+   * @param month the month of the given date, 0 for January.
4e62ec
+   * @param day the day of month
4e62ec
+   * @param dayOfWeek the day of week; this must match the other fields.
4e62ec
+   * @param millis the millis in the day (in local standard time)
4e62ec
+   * @return the time zone offset in milliseconds.
4e62ec
+   * @throws IllegalArgumentException if arguments are incorrect.
4e62ec
+   */
4e62ec
+  public int getOffset(int era, int year, int month, int day, int dayOfWeek,
4e62ec
+		       int millis)
4e62ec
+  {
4e62ec
+    if (gmtZone == null)
4e62ec
+      gmtZone = new SimpleTimeZone(0, "GMT");
4e62ec
+
4e62ec
+    if (dayOfWeek < Calendar.SUNDAY || dayOfWeek > Calendar.SATURDAY)
4e62ec
+      throw new IllegalArgumentException("dayOfWeek out of range");
4e62ec
+    if (month < Calendar.JANUARY || month > Calendar.DECEMBER)
4e62ec
+      throw new IllegalArgumentException("month out of range:" + month);
4e62ec
+
4e62ec
+    if (era != GregorianCalendar.AD)
4e62ec
+      return (int) (((transitions[0] << OFFSET_SHIFT) >> OFFSET_SHIFT) * 1000);
4e62ec
+
4e62ec
+    GregorianCalendar cal = new GregorianCalendar((TimeZone) gmtZone);
4e62ec
+    cal.set(year, month, day, 0, 0, 0);
4e62ec
+    if (cal.get(Calendar.DAY_OF_MONTH) != day)
4e62ec
+      throw new IllegalArgumentException("day out of range");
4e62ec
+
4e62ec
+    return getOffset(cal.getTimeInMillis() - rawOffset + millis);
4e62ec
+  }
4e62ec
+
4e62ec
+  private long findTransition(long secs)
4e62ec
+  {
4e62ec
+    if (secs < (transitions[0] >> SECS_SHIFT))
4e62ec
+      return transitions[0];
4e62ec
+
4e62ec
+    if (secs >= (transitions[transitions.length-1] >> SECS_SHIFT))
4e62ec
+      return Long.MAX_VALUE;
4e62ec
+
4e62ec
+    long val = (secs + 1) << SECS_SHIFT;
4e62ec
+    int lo = 1;
4e62ec
+    int hi = transitions.length;
4e62ec
+    int mid = 1;
4e62ec
+    while (lo < hi)
4e62ec
+      {
4e62ec
+	mid = (lo + hi) / 2;
4e62ec
+	// secs < (transitions[mid-1] >> SECS_SHIFT)
4e62ec
+	if (val <= transitions[mid-1])
4e62ec
+	  hi = mid;
4e62ec
+	// secs >= (transitions[mid] >> SECS_SHIFT)
4e62ec
+	else if (val > transitions[mid])
4e62ec
+	  lo = mid + 1;
4e62ec
+	else
4e62ec
+	  break;
4e62ec
+      }
4e62ec
+    return transitions[mid];
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Get the time zone offset for the specified date, modified in case of
4e62ec
+   * daylight savings.  This is the offset to add to UTC to get the local
4e62ec
+   * time.
4e62ec
+   * @param date the date represented in millisecends
4e62ec
+   * since January 1, 1970 00:00:00 GMT.
4e62ec
+   */
4e62ec
+  public int getOffset(long date)
4e62ec
+  {
4e62ec
+    long d = (date >= 0 ? date / 1000 : (date + 1) / 1000 - 1);
4e62ec
+    long transition = findTransition(d);
4e62ec
+
4e62ec
+    // For times on or after last transition use lastRule.
4e62ec
+    if (transition == Long.MAX_VALUE)
4e62ec
+      return lastRule.getOffset(date);
4e62ec
+
4e62ec
+    return (int) (((transition << OFFSET_SHIFT) >> OFFSET_SHIFT) * 1000);
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Returns the time zone offset to GMT in milliseconds, ignoring
4e62ec
+   * day light savings.
4e62ec
+   * @return the time zone offset.
4e62ec
+   */
4e62ec
+  public int getRawOffset()
4e62ec
+  {
4e62ec
+    return rawOffset;
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Sets the standard time zone offset to GMT.
4e62ec
+   * @param rawOffset The time offset from GMT in milliseconds.
4e62ec
+   */
4e62ec
+  public void setRawOffset(int rawOffset)
4e62ec
+  {
4e62ec
+    this.rawOffset = rawOffset;
4e62ec
+    lastRule.setRawOffset(rawOffset);
4e62ec
+  }
4e62ec
+
4e62ec
+  private void computeDSTSavings()
4e62ec
+  {
4e62ec
+    if (lastRule.useDaylightTime())
4e62ec
+      {
4e62ec
+	dstSavings = lastRule.getDSTSavings();
4e62ec
+	useDaylight = true;
4e62ec
+      }
4e62ec
+    else
4e62ec
+      {
4e62ec
+	dstSavings = 0;
4e62ec
+	useDaylight = false;
4e62ec
+	// lastRule might say no DST is in effect simply because
4e62ec
+	// the DST rules are too complex for SimpleTimeZone, say
4e62ec
+	// for Asia/Jerusalem.
4e62ec
+	// Look at the last DST offset if it is newer than current time.
4e62ec
+	long currentSecs = System.currentTimeMillis() / 1000;
4e62ec
+	int i;
4e62ec
+	for (i = transitions.length - 1;
4e62ec
+	     i >= 0 && currentSecs < (transitions[i] >> SECS_SHIFT);
4e62ec
+	     i--)
4e62ec
+	  if ((transitions[i] & IS_DST) != 0)
4e62ec
+	    {
4e62ec
+	      dstSavings = (int) (((transitions[i] << OFFSET_SHIFT)
4e62ec
+				   >> OFFSET_SHIFT) * 1000)
4e62ec
+			   - rawOffset;
4e62ec
+	      useDaylight = true;
4e62ec
+	      break;
4e62ec
+	    }
4e62ec
+      }
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Gets the daylight savings offset.  This is a positive offset in
4e62ec
+   * milliseconds with respect to standard time.  Typically this
4e62ec
+   * is one hour, but for some time zones this may be half an our.
4e62ec
+   * @return the daylight savings offset in milliseconds.
4e62ec
+   */
4e62ec
+  public int getDSTSavings()
4e62ec
+  {
4e62ec
+    return dstSavings;
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Returns if this time zone uses daylight savings time.
4e62ec
+   * @return true, if we use daylight savings time, false otherwise.
4e62ec
+   */
4e62ec
+  public boolean useDaylightTime()
4e62ec
+  {
4e62ec
+    return useDaylight;
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Determines if the given date is in daylight savings time.
4e62ec
+   * @return true, if it is in daylight savings time, false otherwise.
4e62ec
+   */
4e62ec
+  public boolean inDaylightTime(Date date)
4e62ec
+  {
4e62ec
+    long d = date.getTime();
4e62ec
+    d = (d >= 0 ? d / 1000 : (d + 1) / 1000 - 1);
4e62ec
+    long transition = findTransition(d);
4e62ec
+
4e62ec
+    // For times on or after last transition use lastRule.
4e62ec
+    if (transition == Long.MAX_VALUE)
4e62ec
+      return lastRule.inDaylightTime(date);
4e62ec
+
4e62ec
+    return (transition & IS_DST) != 0;
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Generates the hashCode for the SimpleDateFormat object.  It is
4e62ec
+   * the rawOffset, possibly, if useDaylightSavings is true, xored
4e62ec
+   * with startYear, startMonth, startDayOfWeekInMonth, ..., endTime.
4e62ec
+   */
4e62ec
+  public synchronized int hashCode()
4e62ec
+  {
4e62ec
+    int hash = lastRule.hashCode();
4e62ec
+    // FIXME - hash transitions?
4e62ec
+    return hash;
4e62ec
+  }
4e62ec
+
4e62ec
+  public synchronized boolean equals(Object o)
4e62ec
+  {
4e62ec
+    if (! hasSameRules((TimeZone) o))
4e62ec
+      return false;
4e62ec
+
4e62ec
+    ZoneInfo zone = (ZoneInfo) o;
4e62ec
+    return getID().equals(zone.getID());
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Test if the other time zone uses the same rule and only
4e62ec
+   * possibly differs in ID.  This implementation for this particular
4e62ec
+   * class will return true if the other object is a ZoneInfo,
4e62ec
+   * the raw offsets and useDaylight are identical and if useDaylight
4e62ec
+   * is true, also the start and end datas are identical.
4e62ec
+   * @return true if this zone uses the same rule.
4e62ec
+   */
4e62ec
+  public boolean hasSameRules(TimeZone o)
4e62ec
+  {
4e62ec
+    if (this == o)
4e62ec
+      return true;
4e62ec
+    if (! (o instanceof ZoneInfo))
4e62ec
+      return false;
4e62ec
+    ZoneInfo zone = (ZoneInfo) o;
4e62ec
+    if (zone.hashCode() != hashCode() || rawOffset != zone.rawOffset)
4e62ec
+      return false;
4e62ec
+    if (! lastRule.equals(zone.lastRule))
4e62ec
+      return false;
4e62ec
+    // FIXME - compare transitions?
4e62ec
+    return true;
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Returns a string representation of this ZoneInfo object.
4e62ec
+   * @return a string representation of this ZoneInfo object.
4e62ec
+   */
4e62ec
+  public String toString()
4e62ec
+  {
4e62ec
+    return getClass().getName() + "[" + "id=" + getID() + ",offset="
4e62ec
+	   + rawOffset + ",transitions=" + transitions.length
4e62ec
+	   + ",useDaylight=" + useDaylight
4e62ec
+	   + (useDaylight ? (",dstSavings=" + dstSavings) : "")
4e62ec
+	   + ",lastRule=" + lastRule.toString() + "]";
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Reads zic(8) compiled timezone data file from file
4e62ec
+   * and returns a TimeZone class describing it, either
4e62ec
+   * SimpleTimeZone or ZoneInfo depending on whether
4e62ec
+   * it can be described by SimpleTimeZone rule or not.
4e62ec
+   */
4e62ec
+  public static TimeZone readTZFile(String id, String file)
4e62ec
+  {
4e62ec
+    DataInputStream dis = null;
4e62ec
+    try
4e62ec
+      {
4e62ec
+	FileInputStream fis = new FileInputStream(file);
4e62ec
+	BufferedInputStream bis = new BufferedInputStream(fis);
4e62ec
+	dis = new DataInputStream(bis);
4e62ec
+
4e62ec
+	// Make sure we are reading a tzfile.
4e62ec
+	byte[] tzif = new byte[5];
4e62ec
+	dis.readFully(tzif);
4e62ec
+	int tzif2 = 4;
4e62ec
+	if (tzif[0] == 'T' && tzif[1] == 'Z'
4e62ec
+	    && tzif[2] == 'i' && tzif[3] == 'f')
4e62ec
+	  {
4e62ec
+	    if (tzif[4] >= '2')
4e62ec
+	      tzif2 = 8;
4e62ec
+	    // Reserved bytes
4e62ec
+	    skipFully(dis, 16 - 1);
4e62ec
+	  }
4e62ec
+	else
4e62ec
+	  // Darwin has tzdata files that don't start with the TZif marker
4e62ec
+	  skipFully(dis, 16 - 5);
4e62ec
+
4e62ec
+	int ttisgmtcnt = dis.readInt();
4e62ec
+	int ttisstdcnt = dis.readInt();
4e62ec
+	int leapcnt = dis.readInt();
4e62ec
+	int timecnt = dis.readInt();
4e62ec
+	int typecnt = dis.readInt();
4e62ec
+	int charcnt = dis.readInt();
4e62ec
+	if (tzif2 == 8)
4e62ec
+	  {
4e62ec
+	    skipFully(dis, timecnt * (4 + 1) + typecnt * (4 + 1 + 1) + charcnt
4e62ec
+			   + leapcnt * (4 + 4) + ttisgmtcnt + ttisstdcnt);
4e62ec
+
4e62ec
+	    dis.readFully(tzif);
4e62ec
+	    if (tzif[0] != 'T' || tzif[1] != 'Z' || tzif[2] != 'i'
4e62ec
+		|| tzif[3] != 'f' || tzif[4] < '2')
4e62ec
+	      return null;
4e62ec
+
4e62ec
+	    // Reserved bytes
4e62ec
+	    skipFully(dis, 16 - 1);
4e62ec
+	    ttisgmtcnt = dis.readInt();
4e62ec
+	    ttisstdcnt = dis.readInt();
4e62ec
+	    leapcnt = dis.readInt();
4e62ec
+	    timecnt = dis.readInt();
4e62ec
+	    typecnt = dis.readInt();
4e62ec
+	    charcnt = dis.readInt();
4e62ec
+	  }
4e62ec
+
4e62ec
+	// Sanity checks
4e62ec
+	if (typecnt <= 0 || timecnt < 0 || charcnt < 0
4e62ec
+	    || leapcnt < 0 || ttisgmtcnt < 0 || ttisstdcnt < 0
4e62ec
+	    || ttisgmtcnt > typecnt || ttisstdcnt > typecnt)
4e62ec
+	  return null;
4e62ec
+
4e62ec
+	// Transition times
4e62ec
+	long[] times = new long[timecnt];
4e62ec
+	for (int i = 0; i < timecnt; i++)
4e62ec
+	  if (tzif2 == 8)
4e62ec
+	    times[i] = dis.readLong();
4e62ec
+	  else
4e62ec
+	    times[i] = (long) dis.readInt();
4e62ec
+
4e62ec
+	// Transition types
4e62ec
+	int[] types = new int[timecnt];
4e62ec
+	for (int i = 0; i < timecnt; i++)
4e62ec
+	  {
4e62ec
+	    types[i] = dis.readByte();
4e62ec
+	    if (types[i] < 0)
4e62ec
+	      types[i] += 256;
4e62ec
+	    if (types[i] >= typecnt)
4e62ec
+	      return null;
4e62ec
+	  }
4e62ec
+
4e62ec
+	// Types
4e62ec
+	int[] offsets = new int[typecnt];
4e62ec
+	int[] typeflags = new int[typecnt];
4e62ec
+	for (int i = 0; i < typecnt; i++)
4e62ec
+	  {
4e62ec
+	    offsets[i] = dis.readInt();
4e62ec
+	    if (offsets[i] >= IS_DST / 2 || offsets[i] <= -IS_DST / 2)
4e62ec
+	      return null;
4e62ec
+	    int dst = dis.readByte();
4e62ec
+	    int abbrind = dis.readByte();
4e62ec
+	    if (abbrind < 0)
4e62ec
+	      abbrind += 256;
4e62ec
+	    if (abbrind >= charcnt)
4e62ec
+	      return null;
4e62ec
+	    typeflags[i] = (dst != 0 ? (1 << 8) : 0) + abbrind;
4e62ec
+	  }
4e62ec
+
4e62ec
+	// Abbrev names
4e62ec
+	byte[] names = new byte[charcnt];
4e62ec
+	dis.readFully(names);
4e62ec
+
4e62ec
+	// Leap transitions, for now ignore
4e62ec
+	skipFully(dis, leapcnt * (tzif2 + 4) + ttisstdcnt + ttisgmtcnt);
4e62ec
+
4e62ec
+	// tzIf2 format has optional POSIX TZ env string
4e62ec
+	String tzstr = null;
4e62ec
+	if (tzif2 == 8 && dis.readByte() == '\n')
4e62ec
+	  {
4e62ec
+	    tzstr = dis.readLine();
4e62ec
+	    if (tzstr.length() <= 0)
4e62ec
+	      tzstr = null;
4e62ec
+	  }
4e62ec
+
4e62ec
+	// Get std/dst_offset and dst/non-dst time zone names.
4e62ec
+	int std_ind = -1;
4e62ec
+	int dst_ind = -1;
4e62ec
+	if (timecnt == 0)
4e62ec
+	  std_ind = 0;
4e62ec
+	else
4e62ec
+	  for (int i = timecnt - 1; i >= 0; i--)
4e62ec
+	    {
4e62ec
+	      if (std_ind == -1 && (typeflags[types[i]] & (1 << 8)) == 0)
4e62ec
+		std_ind = types[i];
4e62ec
+	      else if (dst_ind == -1 && (typeflags[types[i]] & (1 << 8)) != 0)
4e62ec
+		dst_ind = types[i];
4e62ec
+	      if (dst_ind != -1 && std_ind != -1)
4e62ec
+		break;
4e62ec
+	    }
4e62ec
+
4e62ec
+	if (std_ind == -1)
4e62ec
+	  return null;
4e62ec
+
4e62ec
+	int j = typeflags[std_ind] & 255;
4e62ec
+	while (j < charcnt && names[j] != 0)
4e62ec
+	  j++;
4e62ec
+	String std_zonename = new String(names, typeflags[std_ind] & 255,
4e62ec
+					 j - (typeflags[std_ind] & 255),
4e62ec
+					 "ASCII");
4e62ec
+
4e62ec
+	String dst_zonename = "";
4e62ec
+	if (dst_ind != -1)
4e62ec
+	  {
4e62ec
+	    j = typeflags[dst_ind] & 255;
4e62ec
+	    while (j < charcnt && names[j] != 0)
4e62ec
+	      j++;
4e62ec
+	    dst_zonename = new String(names, typeflags[dst_ind] & 255,
4e62ec
+				      j - (typeflags[dst_ind] & 255), "ASCII");
4e62ec
+	  }
4e62ec
+
4e62ec
+	// Only use gmt offset when necessary.
4e62ec
+	// Also special case GMT+/- timezones.
4e62ec
+	String std_offset_string = "";
4e62ec
+	String dst_offset_string = "";
4e62ec
+	if (tzstr == null
4e62ec
+	    && (dst_ind != -1
4e62ec
+		|| (offsets[std_ind] != 0
4e62ec
+		    && !std_zonename.startsWith("GMT+")
4e62ec
+		    && !std_zonename.startsWith("GMT-"))))
4e62ec
+	  {
4e62ec
+	    std_offset_string = Integer.toString(-offsets[std_ind] / 3600);
4e62ec
+	    int seconds = -offsets[std_ind] % 3600;
4e62ec
+	    if (seconds != 0)
4e62ec
+	      {
4e62ec
+		if (seconds < 0)
4e62ec
+		  seconds *= -1;
4e62ec
+		if (seconds < 600)
4e62ec
+		  std_offset_string += ":0" + Integer.toString(seconds / 60);
4e62ec
+		else
4e62ec
+		  std_offset_string += ":" + Integer.toString(seconds / 60);
4e62ec
+		seconds = seconds % 60;
4e62ec
+		if (seconds >= 10)
4e62ec
+		  std_offset_string += ":" + Integer.toString(seconds);
4e62ec
+		else if (seconds > 0)
4e62ec
+		  std_offset_string += ":0" + Integer.toString(seconds);
4e62ec
+	      }
4e62ec
+
4e62ec
+	    if (dst_ind != -1 && offsets[dst_ind] != offsets[std_ind] + 3600)
4e62ec
+	      {
4e62ec
+		dst_offset_string = Integer.toString(-offsets[dst_ind] / 3600);
4e62ec
+		seconds = -offsets[dst_ind] % 3600;
4e62ec
+		if (seconds != 0)
4e62ec
+		  {
4e62ec
+		    if (seconds < 0)
4e62ec
+		      seconds *= -1;
4e62ec
+		    if (seconds < 600)
4e62ec
+		      dst_offset_string
4e62ec
+			+= ":0" + Integer.toString(seconds / 60);
4e62ec
+		    else
4e62ec
+		      dst_offset_string
4e62ec
+			+= ":" + Integer.toString(seconds / 60);
4e62ec
+		    seconds = seconds % 60;
4e62ec
+		    if (seconds >= 10)
4e62ec
+		      dst_offset_string += ":" + Integer.toString(seconds);
4e62ec
+		    else if (seconds > 0)
4e62ec
+		      dst_offset_string += ":0" + Integer.toString(seconds);
4e62ec
+		  }
4e62ec
+	      }
4e62ec
+	  }
4e62ec
+
4e62ec
+	/*
4e62ec
+	 * If no tzIf2 POSIX TZ string is available and the timezone
4e62ec
+	 * uses DST, try to guess the last rule by trying to make
4e62ec
+	 * sense from transitions at 5 years in the future and onwards.
4e62ec
+	 * tzdata actually uses only 3 forms of rules:
4e62ec
+	 * fixed date within a month, e.g. change on April, 5th
4e62ec
+	 * 1st weekday on or after Nth: change on Sun>=15 in April
4e62ec
+	 * last weekday in a month: change on lastSun in April
4e62ec
+	 */
4e62ec
+	String[] change_spec = { null, null };
4e62ec
+	if (tzstr == null && dst_ind != -1 && timecnt > 10)
4e62ec
+	  {
4e62ec
+	    long nowPlus5y = System.currentTimeMillis() / 1000
4e62ec
+			     + 5 * 365 * 86400;
4e62ec
+	    int first;
4e62ec
+
4e62ec
+	    for (first = timecnt - 1; first >= 0; first--)
4e62ec
+	      if (times[first] < nowPlus5y
4e62ec
+		  || (types[first] != std_ind && types[first] != dst_ind)
4e62ec
+		  || types[first] != types[timecnt - 2 + ((first ^ timecnt) & 1)])
4e62ec
+		break;
4e62ec
+	    first++;
4e62ec
+
4e62ec
+	    if (timecnt - first >= 10 && types[timecnt - 1] != types[timecnt - 2])
4e62ec
+	      {
4e62ec
+		GregorianCalendar cal
4e62ec
+		  = new GregorianCalendar(new SimpleTimeZone(0, "GMT"));
4e62ec
+
4e62ec
+		int[] values = new int[2 * 11];
4e62ec
+		int i;
4e62ec
+		for (i = timecnt - 1; i >= first; i--)
4e62ec
+		  {
4e62ec
+		    int base = (i % 2) * 11;
4e62ec
+		    int offset = offsets[types[i > first ? i - 1 : i + 1]];
4e62ec
+		    cal.setTimeInMillis((times[i] + offset) * 1000);
4e62ec
+		    if (i >= timecnt - 2)
4e62ec
+		      {
4e62ec
+			values[base + 0] = cal.get(Calendar.YEAR);
4e62ec
+			values[base + 1] = cal.get(Calendar.MONTH);
4e62ec
+			values[base + 2] = cal.get(Calendar.DAY_OF_MONTH);
4e62ec
+			values[base + 3]
4e62ec
+			  = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
4e62ec
+			values[base + 4] = cal.get(Calendar.DAY_OF_WEEK);
4e62ec
+			values[base + 5] = cal.get(Calendar.HOUR_OF_DAY);
4e62ec
+			values[base + 6] = cal.get(Calendar.MINUTE);
4e62ec
+			values[base + 7] = cal.get(Calendar.SECOND);
4e62ec
+			values[base + 8] = values[base + 2]; // Range start
4e62ec
+			values[base + 9] = values[base + 2]; // Range end
4e62ec
+			values[base + 10] = 0; // Determined type
4e62ec
+		      }
4e62ec
+		    else
4e62ec
+		      {
4e62ec
+			int year = cal.get(Calendar.YEAR);
4e62ec
+			int month = cal.get(Calendar.MONTH);
4e62ec
+			int day_of_month = cal.get(Calendar.DAY_OF_MONTH);
4e62ec
+			int month_days
4e62ec
+			  = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
4e62ec
+			int day_of_week = cal.get(Calendar.DAY_OF_WEEK);
4e62ec
+			int hour = cal.get(Calendar.HOUR_OF_DAY);
4e62ec
+			int minute = cal.get(Calendar.MINUTE);
4e62ec
+			int second = cal.get(Calendar.SECOND);
4e62ec
+			if (year != values[base + 0] - 1
4e62ec
+			    || month != values[base + 1]
4e62ec
+			    || hour != values[base + 5]
4e62ec
+			    || minute != values[base + 6]
4e62ec
+			    || second != values[base + 7])
4e62ec
+			  break;
4e62ec
+			if (day_of_week == values[base + 4])
4e62ec
+			  {
4e62ec
+			    // Either a Sun>=8 or lastSun rule.
4e62ec
+			    if (day_of_month < values[base + 8])
4e62ec
+			      values[base + 8] = day_of_month;
4e62ec
+			    if (day_of_month > values[base + 9])
4e62ec
+			      values[base + 9] = day_of_month;
4e62ec
+			    if (values[base + 10] < 0)
4e62ec
+			      break;
4e62ec
+			    if (values[base + 10] == 0)
4e62ec
+			      {
4e62ec
+				values[base + 10] = 1;
4e62ec
+				// If day of month > 28, this is
4e62ec
+				// certainly lastSun rule.
4e62ec
+				if (values[base + 2] > 28)
4e62ec
+				  values[base + 2] = 3;
4e62ec
+				// If day of month isn't in the last
4e62ec
+				// week, it can't be lastSun rule.
4e62ec
+				else if (values[base + 2]
4e62ec
+					 <= values[base + 3] - 7)
4e62ec
+				  values[base + 3] = 2;
4e62ec
+			      }
4e62ec
+			    if (values[base + 10] == 1)
4e62ec
+			      {
4e62ec
+				// If day of month is > 28, this is
4e62ec
+				// certainly lastSun rule.
4e62ec
+				if (day_of_month > 28)
4e62ec
+				  values[base + 10] = 3;
4e62ec
+				// If day of month isn't in the last
4e62ec
+				// week, it can't be lastSun rule.
4e62ec
+				else if (day_of_month <= month_days - 7)
4e62ec
+				  values[base + 10] = 2;
4e62ec
+			      }
4e62ec
+			    else if ((values[base + 10] == 2
4e62ec
+				      && day_of_month > 28)
4e62ec
+				     || (values[base + 10] == 3
4e62ec
+					 && day_of_month <= month_days - 7))
4e62ec
+			      break;
4e62ec
+			  }
4e62ec
+			else
4e62ec
+			  {
4e62ec
+			    // Must be fixed day in month rule.
4e62ec
+			    if (day_of_month != values[base + 2]
4e62ec
+				|| values[base + 10] > 0)
4e62ec
+			      break;
4e62ec
+			    values[base + 4] = day_of_week;
4e62ec
+			    values[base + 10] = -1;
4e62ec
+			  }
4e62ec
+			values[base + 0] -= 1;
4e62ec
+		      }
4e62ec
+		  }
4e62ec
+
4e62ec
+		if (i < first)
4e62ec
+		  {
4e62ec
+		    for (i = 0; i < 2; i++)
4e62ec
+		      {
4e62ec
+			int base = 11 * i;
4e62ec
+			if (values[base + 10] == 0)
4e62ec
+			  continue;
4e62ec
+			if (values[base + 10] == -1)
4e62ec
+			  {
4e62ec
+			    int[] dayCount
4e62ec
+			      = { 0, 31, 59, 90, 120, 151,
4e62ec
+				  181, 212, 243, 273, 304, 334 };
4e62ec
+			    int d = dayCount[values[base + 1]
4e62ec
+					     - Calendar.JANUARY];
4e62ec
+			    d += values[base + 2];
4e62ec
+			    change_spec[i] = ",J" + Integer.toString(d);
4e62ec
+			  }
4e62ec
+			else if (values[base + 10] == 2)
4e62ec
+			  {
4e62ec
+			    // If we haven't seen all days of the week,
4e62ec
+			    // we can't be sure what the rule really is.
4e62ec
+			    if (values[base + 8] + 6 != values[base + 9])
4e62ec
+			      continue;
4e62ec
+
4e62ec
+			    int d;
4e62ec
+			    d = values[base + 1] - Calendar.JANUARY + 1;
4e62ec
+			    // E.g. Sun >= 5 is not representable in POSIX
4e62ec
+			    // TZ env string, use ",Am.n.d" extension
4e62ec
+			    // where m is month 1 .. 12, n is the date on
4e62ec
+			    // or after which it happens and d is day
4e62ec
+			    // of the week, 0 .. 6.  So Sun >= 5 in April
4e62ec
+			    // is ",A4.5.0".
4e62ec
+			    if ((values[base + 8] % 7) == 1)
4e62ec
+			      {
4e62ec
+				change_spec[i] = ",M" + Integer.toString(d);
4e62ec
+				d = (values[base + 8] + 6) / 7;
4e62ec
+			      }
4e62ec
+			    else
4e62ec
+			      {
4e62ec
+				change_spec[i] = ",A" + Integer.toString(d);
4e62ec
+				d = values[base + 8];
4e62ec
+			      }
4e62ec
+			    change_spec[i] += "." + Integer.toString(d);
4e62ec
+			    d = values[base + 4] - Calendar.SUNDAY;
4e62ec
+			    change_spec[i] += "." + Integer.toString(d);
4e62ec
+			  }
4e62ec
+			else
4e62ec
+			  {
4e62ec
+			    // If we don't know whether this is lastSun or
4e62ec
+			    // Sun >= 22 rule.  That can be either because
4e62ec
+			    // there was insufficient number of
4e62ec
+			    // transitions, or February, where it is quite
4e62ec
+			    // probable we haven't seen any 29th dates.
4e62ec
+			    // For February, assume lastSun rule, otherwise
4e62ec
+			    // punt.
4e62ec
+			    if (values[base + 10] == 1
4e62ec
+				&& values[base + 1] != Calendar.FEBRUARY)
4e62ec
+			      continue;
4e62ec
+
4e62ec
+			    int d;
4e62ec
+			    d = values[base + 1] - Calendar.JANUARY + 1;
4e62ec
+			    change_spec[i] = ",M" + Integer.toString(d);
4e62ec
+			    d = values[base + 4] - Calendar.SUNDAY;
4e62ec
+			    change_spec[i] += ".5." + Integer.toString(d);
4e62ec
+			  }
4e62ec
+
4e62ec
+			// Don't add time specification if time is
4e62ec
+			// 02:00:00.
4e62ec
+			if (values[base + 5] != 2
4e62ec
+			    || values[base + 6] != 0
4e62ec
+			    || values[base + 7] != 0)
4e62ec
+			  {
4e62ec
+			    int d = values[base + 5];
4e62ec
+			    change_spec[i] += "/" + Integer.toString(d);
4e62ec
+			    if (values[base + 6] != 0 || values[base + 7] != 0)
4e62ec
+			      {
4e62ec
+				d = values[base + 6];
4e62ec
+				if (d < 10)
4e62ec
+				  change_spec[i]
4e62ec
+				    += ":0" + Integer.toString(d);
4e62ec
+				else
4e62ec
+				  change_spec[i] += ":" + Integer.toString(d);
4e62ec
+				d = values[base + 7];
4e62ec
+				if (d >= 10)
4e62ec
+				   change_spec[i]
4e62ec
+				     += ":" + Integer.toString(d);
4e62ec
+				else if (d > 0)
4e62ec
+				  change_spec[i]
4e62ec
+				    += ":0" + Integer.toString(d);
4e62ec
+			      }
4e62ec
+			  }
4e62ec
+		      }
4e62ec
+		    if (types[(timecnt - 1) & -2] == std_ind)
4e62ec
+		      {
4e62ec
+			String tmp = change_spec[0];
4e62ec
+			change_spec[0] = change_spec[1];
4e62ec
+			change_spec[1] = tmp;
4e62ec
+		      }
4e62ec
+		  }
4e62ec
+	      }
4e62ec
+	  }
4e62ec
+
4e62ec
+	if (tzstr == null)
4e62ec
+	  {
4e62ec
+	    tzstr = std_zonename + std_offset_string;
4e62ec
+	    if (change_spec[0] != null && change_spec[1] != null)
4e62ec
+	      tzstr += dst_zonename + dst_offset_string
4e62ec
+		       + change_spec[0] + change_spec[1];
4e62ec
+	  }
4e62ec
+
4e62ec
+	if (timecnt == 0)
4e62ec
+	  return new SimpleTimeZone(offsets[std_ind] * 1000,
4e62ec
+				    id != null ? id : tzstr);
4e62ec
+
4e62ec
+	SimpleTimeZone endRule = createLastRule(tzstr);
4e62ec
+	if (endRule == null)
4e62ec
+	  return null;
4e62ec
+
4e62ec
+	/* Finally adjust the times array into the form the constructor
4e62ec
+	 * expects.  times[0] is special, the offset and DST flag there
4e62ec
+	 * are for all times before that transition.  Use the first non-DST
4e62ec
+	 * type.  For all other transitions, the data file has the type
4e62ec
+	 * (<offset, isdst, zonename>) for the time interval starting
4e62ec
+	 */
4e62ec
+	for (int i = 0; i < typecnt; i++)
4e62ec
+	  if ((typeflags[i] & (1 << 8)) == 0)
4e62ec
+	    {
4e62ec
+	      times[0] = (times[0] << SECS_SHIFT) | (offsets[i] & OFFSET_MASK);
4e62ec
+	      break;
4e62ec
+	    }
4e62ec
+
4e62ec
+	for (int i = 1; i < timecnt; i++)
4e62ec
+	  times[i] = (times[i] << SECS_SHIFT)
4e62ec
+		     | (offsets[types[i - 1]] & OFFSET_MASK)
4e62ec
+		     | ((typeflags[types[i - 1]] & (1 << 8)) != 0 ? IS_DST : 0);
4e62ec
+
4e62ec
+	return new ZoneInfo(offsets[std_ind] * 1000, id != null ? id : tzstr,
4e62ec
+			    times, endRule);
4e62ec
+      }
4e62ec
+    catch (IOException ioe)
4e62ec
+      {
4e62ec
+	// Parse error, not a proper tzfile.
4e62ec
+	return null;
4e62ec
+      }
4e62ec
+    finally
4e62ec
+      {
4e62ec
+	try
4e62ec
+	  {
4e62ec
+	    if (dis != null)
4e62ec
+	      dis.close();
4e62ec
+	  }
4e62ec
+	catch(IOException ioe)
4e62ec
+	  {
4e62ec
+	    // Error while close, nothing we can do.
4e62ec
+	  }
4e62ec
+      }
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Skips the requested number of bytes in the given InputStream.
4e62ec
+   * Throws EOFException if not enough bytes could be skipped.
4e62ec
+   * Negative numbers of bytes to skip are ignored.
4e62ec
+   */
4e62ec
+  private static void skipFully(InputStream is, long l) throws IOException
4e62ec
+  {
4e62ec
+    while (l > 0)
4e62ec
+      {
4e62ec
+	long k = is.skip(l);
4e62ec
+	if (k <= 0)
4e62ec
+	  throw new EOFException();
4e62ec
+	l -= k;
4e62ec
+      }
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Create a SimpleTimeZone from a POSIX TZ environment string,
4e62ec
+   * see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html
4e62ec
+   * for details.
4e62ec
+   * It supports also an extension, where Am.n.d rule (m 1 .. 12, n 1 .. 25, d
4e62ec
+   * 0 .. 6) describes day of week d on or after nth day of month m.
4e62ec
+   * Say A4.5.0 is Sun>=5 in April.
4e62ec
+   */
4e62ec
+  private static SimpleTimeZone createLastRule(String tzstr)
4e62ec
+  {
4e62ec
+    String stdName = null;
4e62ec
+    int stdOffs;
4e62ec
+    int dstOffs;
4e62ec
+    try
4e62ec
+      {
4e62ec
+	int idLength = tzstr.length();
4e62ec
+
4e62ec
+	int index = 0;
4e62ec
+	int prevIndex;
4e62ec
+	char c;
4e62ec
+
4e62ec
+	// get std
4e62ec
+	do
4e62ec
+	  c = tzstr.charAt(index);
4e62ec
+	while (c != '+' && c != '-' && c != ',' && c != ':'
4e62ec
+	       && ! Character.isDigit(c) && c != '\0' && ++index < idLength);
4e62ec
+
4e62ec
+	if (index >= idLength)
4e62ec
+	  return new SimpleTimeZone(0, tzstr);
4e62ec
+
4e62ec
+	stdName = tzstr.substring(0, index);
4e62ec
+	prevIndex = index;
4e62ec
+
4e62ec
+	// get the std offset
4e62ec
+	do
4e62ec
+	  c = tzstr.charAt(index++);
4e62ec
+	while ((c == '-' || c == '+' || c == ':' || Character.isDigit(c))
4e62ec
+	       && index < idLength);
4e62ec
+	if (index < idLength)
4e62ec
+	  index--;
4e62ec
+
4e62ec
+	{ // convert the dst string to a millis number
4e62ec
+	    String offset = tzstr.substring(prevIndex, index);
4e62ec
+	    prevIndex = index;
4e62ec
+
4e62ec
+	    if (offset.charAt(0) == '+' || offset.charAt(0) == '-')
4e62ec
+	      stdOffs = parseTime(offset.substring(1));
4e62ec
+	    else
4e62ec
+	      stdOffs = parseTime(offset);
4e62ec
+
4e62ec
+	    if (offset.charAt(0) == '-')
4e62ec
+	      stdOffs = -stdOffs;
4e62ec
+
4e62ec
+	    // TZ timezone offsets are positive when WEST of the meridian.
4e62ec
+	    stdOffs = -stdOffs;
4e62ec
+	}
4e62ec
+
4e62ec
+	// Done yet? (Format: std offset)
4e62ec
+	if (index >= idLength)
4e62ec
+	  return new SimpleTimeZone(stdOffs, stdName);
4e62ec
+
4e62ec
+	// get dst
4e62ec
+	do
4e62ec
+	  c = tzstr.charAt(index);
4e62ec
+	while (c != '+' && c != '-' && c != ',' && c != ':'
4e62ec
+	       && ! Character.isDigit(c) && c != '\0' && ++index < idLength);
4e62ec
+
4e62ec
+	// Done yet? (Format: std offset dst)
4e62ec
+	if (index >= idLength)
4e62ec
+	  return new SimpleTimeZone(stdOffs, stdName);
4e62ec
+
4e62ec
+	// get the dst offset
4e62ec
+	prevIndex = index;
4e62ec
+	do
4e62ec
+	  c = tzstr.charAt(index++);
4e62ec
+	while ((c == '-' || c == '+' || c == ':' || Character.isDigit(c))
4e62ec
+	       && index < idLength);
4e62ec
+	if (index < idLength)
4e62ec
+	  index--;
4e62ec
+
4e62ec
+	if (index == prevIndex && (c == ',' || c == ';'))
4e62ec
+	  {
4e62ec
+	    // Missing dst offset defaults to one hour ahead of standard
4e62ec
+	    // time.
4e62ec
+	    dstOffs = stdOffs + 60 * 60 * 1000;
4e62ec
+	  }
4e62ec
+	else
4e62ec
+	  { // convert the dst string to a millis number
4e62ec
+	    String offset = tzstr.substring(prevIndex, index);
4e62ec
+	    prevIndex = index;
4e62ec
+
4e62ec
+	    if (offset.charAt(0) == '+' || offset.charAt(0) == '-')
4e62ec
+	      dstOffs = parseTime(offset.substring(1));
4e62ec
+	    else
4e62ec
+	      dstOffs = parseTime(offset);
4e62ec
+
4e62ec
+	    if (offset.charAt(0) == '-')
4e62ec
+	      dstOffs = -dstOffs;
4e62ec
+
4e62ec
+	    // TZ timezone offsets are positive when WEST of the meridian.
4e62ec
+	    dstOffs = -dstOffs;
4e62ec
+	  }
4e62ec
+
4e62ec
+	// Done yet? (Format: std offset dst offset)
4e62ec
+	if (index >= idLength)
4e62ec
+	  return new SimpleTimeZone(stdOffs, stdName);
4e62ec
+
4e62ec
+	// get the DST rule
4e62ec
+	if (tzstr.charAt(index) == ','
4e62ec
+	    || tzstr.charAt(index) == ';')
4e62ec
+	  {
4e62ec
+	    index++;
4e62ec
+	    int offs = index;
4e62ec
+	    while (tzstr.charAt(index) != ','
4e62ec
+		   && tzstr.charAt(index) != ';')
4e62ec
+	      index++;
4e62ec
+	    String startTime = tzstr.substring(offs, index);
4e62ec
+	    index++;
4e62ec
+	    String endTime = tzstr.substring(index);
4e62ec
+
4e62ec
+	    index = startTime.indexOf('/');
4e62ec
+	    int startMillis;
4e62ec
+	    int endMillis;
4e62ec
+	    String startDate;
4e62ec
+	    String endDate;
4e62ec
+	    if (index != -1)
4e62ec
+	      {
4e62ec
+		startDate = startTime.substring(0, index);
4e62ec
+		startMillis = parseTime(startTime.substring(index + 1));
4e62ec
+	      }
4e62ec
+	    else
4e62ec
+	      {
4e62ec
+		startDate = startTime;
4e62ec
+		// if time isn't given, default to 2:00:00 AM.
4e62ec
+		startMillis = 2 * 60 * 60 * 1000;
4e62ec
+	      }
4e62ec
+	    index = endTime.indexOf('/');
4e62ec
+	    if (index != -1)
4e62ec
+	      {
4e62ec
+		endDate = endTime.substring(0, index);
4e62ec
+		endMillis = parseTime(endTime.substring(index + 1));
4e62ec
+	      }
4e62ec
+	    else
4e62ec
+	      {
4e62ec
+		endDate = endTime;
4e62ec
+		// if time isn't given, default to 2:00:00 AM.
4e62ec
+		endMillis = 2 * 60 * 60 * 1000;
4e62ec
+	      }
4e62ec
+
4e62ec
+	    int[] start = getDateParams(startDate);
4e62ec
+	    int[] end = getDateParams(endDate);
4e62ec
+	    return new SimpleTimeZone(stdOffs, tzstr, start[0], start[1],
4e62ec
+				      start[2], startMillis, end[0], end[1],
4e62ec
+				      end[2], endMillis, (dstOffs - stdOffs));
4e62ec
+	  }
4e62ec
+      }
4e62ec
+
4e62ec
+    catch (IndexOutOfBoundsException _)
4e62ec
+      {
4e62ec
+      }
4e62ec
+    catch (NumberFormatException _)
4e62ec
+      {
4e62ec
+      }
4e62ec
+
4e62ec
+    return null;
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Parses and returns the params for a POSIX TZ date field,
4e62ec
+   * in the format int[]{ month, day, dayOfWeek }, following the
4e62ec
+   * SimpleTimeZone constructor rules.
4e62ec
+   */
4e62ec
+  private static int[] getDateParams(String date)
4e62ec
+  {
4e62ec
+    int[] dayCount = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
4e62ec
+    int month;
4e62ec
+    int type = 0;
4e62ec
+
4e62ec
+    if (date.charAt(0) == 'M' || date.charAt(0) == 'm')
4e62ec
+      type = 1;
4e62ec
+    else if (date.charAt(0) == 'A' || date.charAt(0) == 'a')
4e62ec
+      type = 2;
4e62ec
+
4e62ec
+    if (type > 0)
4e62ec
+      {
4e62ec
+	int day;
4e62ec
+
4e62ec
+	// Month, week of month, day of week
4e62ec
+	// "Mm.w.d".  d is between 0 (Sunday) and 6.  Week w is
4e62ec
+	// between 1 and 5; Week 1 is the first week in which day d
4e62ec
+	// occurs and Week 5 specifies the last d day in the month.
4e62ec
+	// Month m is between 1 and 12.
4e62ec
+
4e62ec
+	// Month, day of month, day of week
4e62ec
+	// ZoneInfo extension, not in POSIX
4e62ec
+	// "Am.n.d".  d is between 0 (Sunday) and 6.  Day of month n is
4e62ec
+	// between 1 and 25.  Month m is between 1 and 12.
4e62ec
+
4e62ec
+	month = Integer.parseInt(date.substring(1, date.indexOf('.')));
4e62ec
+	int week = Integer.parseInt(date.substring(date.indexOf('.') + 1,
4e62ec
+						   date.lastIndexOf('.')));
4e62ec
+	int dayOfWeek = Integer.parseInt(date.substring(date.lastIndexOf('.')
4e62ec
+							+ 1));
4e62ec
+	dayOfWeek++; // Java day of week is one-based, Sunday is first day.
4e62ec
+
4e62ec
+	if (type == 2)
4e62ec
+	  {
4e62ec
+	    day = week;
4e62ec
+	    dayOfWeek = -dayOfWeek;
4e62ec
+	  }
4e62ec
+ 	else if (week == 5)
4e62ec
+ 	  day = -1; // last day of month is -1 in java, 5 in TZ
4e62ec
+ 	else
4e62ec
+	  {
4e62ec
+	    // First day of week starting on or after.  For example,
4e62ec
+	    // to specify the second Sunday of April, set month to
4e62ec
+	    // APRIL, day-of-month to 8, and day-of-week to -SUNDAY.
4e62ec
+	    day = (week - 1) * 7 + 1;
4e62ec
+	    dayOfWeek = -dayOfWeek;
4e62ec
+	  }
4e62ec
+
4e62ec
+	month--; // Java month is zero-based.
4e62ec
+	return new int[] { month, day, dayOfWeek };
4e62ec
+      }
4e62ec
+
4e62ec
+    // julian day, either zero-based 0<=n<=365 (incl feb 29)
4e62ec
+    // or one-based 1<=n<=365 (no feb 29)
4e62ec
+    int julianDay; // Julian day
4e62ec
+
4e62ec
+    if (date.charAt(0) != 'J' || date.charAt(0) != 'j')
4e62ec
+      {
4e62ec
+	julianDay = Integer.parseInt(date.substring(1));
4e62ec
+	julianDay++; // make 1-based
4e62ec
+	// Adjust day count to include feb 29.
4e62ec
+	dayCount = new int[]
4e62ec
+		   {
4e62ec
+		     0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335
4e62ec
+		   };
4e62ec
+      }
4e62ec
+    else
4e62ec
+      // 1-based julian day
4e62ec
+      julianDay = Integer.parseInt(date);
4e62ec
+
4e62ec
+    int i = 11;
4e62ec
+    while (i > 0)
4e62ec
+      if (dayCount[i] < julianDay)
4e62ec
+	break;
4e62ec
+      else
4e62ec
+	i--;
4e62ec
+    julianDay -= dayCount[i];
4e62ec
+    month = i;
4e62ec
+    return new int[] { month, julianDay, 0 };
4e62ec
+  }
4e62ec
+
4e62ec
+  /**
4e62ec
+   * Parses a time field hh[:mm[:ss]], returning the result
4e62ec
+   * in milliseconds. No leading sign.
4e62ec
+   */
4e62ec
+  private static int parseTime(String time)
4e62ec
+  {
4e62ec
+    int millis = 0;
4e62ec
+    int i = 0;
4e62ec
+
4e62ec
+    while (i < time.length())
4e62ec
+      if (time.charAt(i) == ':')
4e62ec
+	break;
4e62ec
+      else
4e62ec
+	i++;
4e62ec
+    millis = 60 * 60 * 1000 * Integer.parseInt(time.substring(0, i));
4e62ec
+    if (i >= time.length())
4e62ec
+      return millis;
4e62ec
+
4e62ec
+    int iprev = ++i;
4e62ec
+    while (i < time.length())
4e62ec
+      if (time.charAt(i) == ':')
4e62ec
+	break;
4e62ec
+      else
4e62ec
+	i++;
4e62ec
+    millis += 60 * 1000 * Integer.parseInt(time.substring(iprev, i));
4e62ec
+    if (i >= time.length())
4e62ec
+      return millis;
4e62ec
+
4e62ec
+    millis += 1000 * Integer.parseInt(time.substring(++i));
4e62ec
+    return millis;
4e62ec
+  }
4e62ec
+}