Blame SOURCES/gcc34-java-zoneinfo.patch

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

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

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

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

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

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

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