/[classpath]/classpath/java/util/SimpleTimeZone.java
ViewVC logotype

Diff of /classpath/java/util/SimpleTimeZone.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18.2.2 by gnu_andrew, Sat Jan 22 02:20:02 2005 UTC revision 1.18.2.3 by gnu_andrew, Mon Jan 24 01:59:54 2005 UTC
# Line 424  public class SimpleTimeZone extends Time Line 424  public class SimpleTimeZone extends Time
424     */     */
425    private int checkRule(int month, int day, int dayOfWeek)    private int checkRule(int month, int day, int dayOfWeek)
426    {    {
     if (month < 0 || month > 11)  
       throw new IllegalArgumentException("month out of range");  
427      int daysInMonth = getDaysInMonth(month, 1);      int daysInMonth = getDaysInMonth(month, 1);
428      if (dayOfWeek == 0)      if (dayOfWeek == 0)
429        {        {
# Line 586  public class SimpleTimeZone extends Time Line 584  public class SimpleTimeZone extends Time
584     *     *
585     * Note that this API isn't incredibly well specified.  It appears that the     * Note that this API isn't incredibly well specified.  It appears that the
586     * after flag must override the parameters, since normally, the day and     * after flag must override the parameters, since normally, the day and
587     * dayofweek can select this.  I.e., if day &lt; 0 and dayOfWeek &lt; 0, on or     * dayofweek can select this.  I.e., if day < 0 and dayOfWeek < 0, on or
588     * before mode is chosen.  But if after == true, this implementation     * before mode is chosen.  But if after == true, this implementation
589     * overrides the signs of the other arguments.  And if dayOfWeek == 0, it     * overrides the signs of the other arguments.  And if dayOfWeek == 0, it
590     * falls back to the behavior in the other APIs.  I guess this should be     * falls back to the behavior in the other APIs.  I guess this should be
# Line 680  public class SimpleTimeZone extends Time Line 678  public class SimpleTimeZone extends Time
678      if (dayOfWeek < Calendar.SUNDAY || dayOfWeek > Calendar.SATURDAY)      if (dayOfWeek < Calendar.SUNDAY || dayOfWeek > Calendar.SATURDAY)
679        throw new IllegalArgumentException("dayOfWeek out of range");        throw new IllegalArgumentException("dayOfWeek out of range");
680      if (month < Calendar.JANUARY || month > Calendar.DECEMBER)      if (month < Calendar.JANUARY || month > Calendar.DECEMBER)
681        throw new IllegalArgumentException("month out of range");        throw new IllegalArgumentException("month out of range:" + month);
682    
683      // This method is called by Calendar, so we mustn't use that class.      // This method is called by Calendar, so we mustn't use that class.
684      int daylightSavings = 0;      int daylightSavings = 0;
# Line 691  public class SimpleTimeZone extends Time Line 689  public class SimpleTimeZone extends Time
689          boolean afterStart = ! isBefore(year, month, day, dayOfWeek, millis,          boolean afterStart = ! isBefore(year, month, day, dayOfWeek, millis,
690                                          startMode, startMonth, startDay,                                          startMode, startMonth, startDay,
691                                          startDayOfWeek, startTime);                                          startDayOfWeek, startTime);
692          boolean beforeEnd = isBefore(year, month, day, dayOfWeek,          boolean beforeEnd = isBefore(year, month, day, dayOfWeek, millis,
693                                       millis + dstSavings, endMode, endMonth,                                       endMode, endMonth, endDay, endDayOfWeek,
694                                       endDay, endDayOfWeek, endTime);                                       endTime);
695    
696          if (startMonth < endMonth)          if (startMonth < endMonth)
697            // use daylight savings, if the date is after the start of            // use daylight savings, if the date is after the start of
# Line 765  public class SimpleTimeZone extends Time Line 763  public class SimpleTimeZone extends Time
763    }    }
764    
765    /**    /**
766     * Returns the number of days in the given month.  It does always     * Returns the number of days in the given month.
767     * use the Gregorian leap year rule.     * Uses gregorian rules prior to 1582 (The default and earliest cutover)
768     * @param month The month, zero based; use one of the Calendar constants.     * @param month The month, zero based; use one of the Calendar constants.
769     * @param year  The year.     * @param year  The year.
770     */     */
771    private int getDaysInMonth(int month, int year)    private int getDaysInMonth(int month, int year)
772    {    {
     // Most of this is copied from GregorianCalendar.getActualMaximum()  
773      if (month == Calendar.FEBRUARY)      if (month == Calendar.FEBRUARY)
774        return ((year & 3) == 0 && (year % 100 != 0 || year % 400 == 0)) ? 29 : 28;        {
775      else if (month < Calendar.AUGUST)          if ((year & 3) != 0)
776        return 31 - (month & 1);            return 28;
777    
778            // Assume default Gregorian cutover,
779            // all years prior to this must be Julian
780            if (year < 1582)
781              return 29;
782    
783            // Gregorian rules
784            return ((year % 100) != 0 || (year % 400) == 0) ? 29 : 28;
785          }
786      else      else
787        return 30 + (month & 1);        return monthArr[month];
788    }    }
789    
790    /**    /**

Legend:
Removed from v.1.18.2.2  
changed lines
  Added in v.1.18.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26