Add new files from Wictor Wilen
authorMiguel de Icaza <miguel@gnome.org>
Mon, 17 Sep 2001 14:29:52 +0000 (14:29 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 17 Sep 2001 14:29:52 +0000 (14:29 -0000)
svn path=/trunk/mcs/; revision=849

mcs/class/corlib/System.Globalization/Calendar.cs
mcs/class/corlib/System.Globalization/CalendarWeekRule.cs [new file with mode: 0644]
mcs/class/corlib/System.Globalization/GregorianCalendar.cs [new file with mode: 0644]
mcs/class/corlib/System.Globalization/JulianCalendar.cs [new file with mode: 0644]

index a9d3fa23100a6b1df407f8fec41deab5a673caa8..7e25429606b043a650e83a1a2642d629e6156f07 100644 (file)
-// 
+// ::MONO
+//
 // System.Globalization.Calendar.cs
 //
-// Nick made it.  (nick@ximian.com)
+// Copyright (C) Wictor Wilén 2001 (wictor@iBizkit.se)
+//
+// Contributors: Marcel Narings, Wictor Wilén
+//
+// Revisions
+// 2001-09-14: First draft
+// 2001-09-15: First release
+//
 //
-// (C) Ximian, Inc.  http://www.ximian.com/
+// TODO: testing
 //
+//
+
+using System;
 
 namespace System.Globalization
 {
+       /// <summary>
+       /// Implmentation of the System.Globalization.Calendar class
+       /// </summary>
        public abstract class Calendar
        {
-               protected Calendar ()
+               /// <summary>
+               /// The Calendar Constructor
+               /// </summary>
+               protected Calendar () 
                {
+                       _MaxDateTime = DateTime.MaxValue;
+                       _MinDateTime = DateTime.MinValue;
                }
+               protected int _TwoDigitYearMax;
 
-               public int CurrentEra ;
+               protected static int[] _DaysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+               protected static int[] _DaysInMonthLeap = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
                
+
+               // these can be overridden, for example using "new protected const int _MinYear = 1;"
+               protected const int _MinYear = 1;
+               protected const int _MaxYear = 9999;
+               protected const int _MinDay = 0;
+               protected const int _MinMonth = 1;
+               protected const int _MaxMonth = 12;
+               protected const int _MinHour = 0;
+               protected const int _MaxHour = 23;
+               protected const int _MinMinute = 0;
+               protected const int _MaxMinute = 59;
+               protected const int _MinSecond = 0;
+               protected const int _MaxSecond = 59;
+               protected const int _MinMillisecond = 0;
+               protected const int _MaxMillisecond = 999;
+
+               private const long _TicksPerMillisecond = 10000;
+               private const long _TicksPerSecond = 10000000;
+               private const long _TicksPerMinute = 600000000;
+               private const long _TicksPerHour = 36000000000;
+               private const long _TicksPerDay = 864000000000;
+               private const long _TicksPerWeek = 6048000000000;
+
+               protected DateTime _MaxDateTime;
+               protected DateTime _MinDateTime;
+
+               
+               /// <summary>
+               /// The Currentera constant
+               /// </summary>
+               public const int CurrentEra = 0;
+               
+               /// <summary>
+               /// Returns an array of the available eras
+               /// </summary>
                public abstract int[] Eras {get;}
 
-               //
-               // This is just a good guess, lets check what .NET actually does with this
-               //
-               int two_digit_year_max = 2029;
-               public virtual int TwoDigitYearMax {
-                       get {
-                               return two_digit_year_max;
+               // DONE!
+               /// <summary>
+               /// The Two digit max
+               /// </summary>
+               public virtual int TwoDigitYearMax 
+               {
+                       get
+                       {
+                               return _TwoDigitYearMax;
+                       } 
+                       set
+                       {
+                               _TwoDigitYearMax = value;
                        }
+               }
 
-                       set {
-                               two_digit_year_max = value;
-                       }
+               // DONE!
+               public virtual DateTime AddDays ( DateTime time, int days )
+               {
+                       return new DateTime(time.Ticks).AddTicks(_TicksPerDay*days);
                }
-               
-               public virtual DateTime AddDays ( DateTime time, int days );
-               public virtual DateTime AddHours ( DateTime time, int hours );
-               public virtual DateTime AddMilliseconds ( DateTime time, double milliseconds );
-               public virtual DateTime AddMinutes ( DateTime time, int minutes );
-               public virtual DateTime AddMonths ( DateTime time, int months );
-               public virtual DateTime AddSeconds ( DateTime time, int seconds );
-               public virtual DateTime AddWeeks ( DateTime time, int weeks );
-               public virtual DateTime AddYears ( DateTime time, int years );
+
+               // DONE!
+               public virtual DateTime AddHours ( DateTime time, int hours )
+               {
+                       return new DateTime(time.Ticks).AddTicks(_TicksPerHour*hours);
+               }
+
+               // DONE!
+               public virtual DateTime AddMilliseconds ( DateTime time, double milliseconds )
+               {
+                       DateTime t = new DateTime(time.Ticks);
+                       return t.AddMilliseconds(milliseconds);
+               }
+
+               // DONE!
+               public virtual DateTime AddMinutes ( DateTime time, int minutes )
+               {
+                       return new DateTime(time.Ticks).AddTicks(_TicksPerMinute * minutes);
+               }
+
+               // DONE!
+               /// <summary>
+               /// Returns a DateTime that is the specified number of months away from the specified DateTime
+               /// </summary>
+               /// <param name="time"></param>
+               /// <param name="months"></param>
+               /// <returns></returns>
+               /// <remarks>Calculates correct comapared to .NET Beta 2</remarks>
+               public virtual DateTime AddMonths ( DateTime time, int months )         
+               {
+                       DateTime t = new DateTime(time.Ticks);
+                       return t.AddMonths(months);
+               }
+
+               // DONE!
+               public virtual DateTime AddSeconds ( DateTime time, int seconds )               
+               {
+                       return new DateTime(time.Ticks).AddTicks(_TicksPerSecond * seconds);
+               }
+
+               // DONE!
+               public virtual DateTime AddWeeks ( DateTime time, int weeks )           
+               {
+                       return new DateTime(time.Ticks).AddTicks(_TicksPerWeek * weeks);
+               }
+
+               // DONE!
+               public virtual DateTime AddYears ( DateTime time, int years )           
+               {
+                       DateTime t = new DateTime(time.Ticks);
+                       return t.AddYears(years);
+               }
+
                
 
+               // DONE!
                public abstract int GetDayOfMonth ( DateTime time );
+
+               // DONE!
                public abstract DayOfWeek GetDayOfWeek ( DateTime time );
+
+               // DONE!
                public abstract int GetDayOfYear ( DateTime time );
-               public virtual int GetDaysInMonth ( int year, int month );
+
+               // DONE!
+               public virtual int GetDaysInMonth ( int year, int month )
+               {
+                       if(year < _MinYear || year > _MaxYear || month < _MinMonth || month > _MaxMonth)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if(this.IsLeapYear(year))
+                               return _DaysInMonthLeap[month];
+                       else
+                               return _DaysInMonth[month];
+               }
+
+               // DONE!
                public abstract int GetDaysInMonth ( int year, int month, int era );
-               public virtual int GetDaysInYear ( int year );
+
+               // DONE!
+               public virtual int GetDaysInYear ( int year)
+               {
+                       if( year < _MinYear || year > _MaxYear)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if(this.IsLeapYear(year))
+                               return 366;
+                       else
+                               return 365;
+               }
+
+               // DONE!
                public abstract int GetDaysInYear ( int year, int era );
+               
+               // DONE!
                public abstract int GetEra ( DateTime time );
-               public virtual int GetHour ( DateTime time );
-               public virtual double GetMilliseconds ( DateTime time );
-               public virtual int GetMinute ( DateTime time );
+               
+               // DONE!
+               public virtual int GetHour ( DateTime time )
+               {
+                       return time.Hour;
+               }
+               // DONE!
+               public virtual double GetMilliseconds ( DateTime time )
+               {
+                       return time.Millisecond;
+               }
+               // DONE!
+               public virtual int GetMinute ( DateTime time )
+               {
+                       return time.Minute;
+               }
+
+               // DONE!
                public abstract int GetMonth ( DateTime time );
-               public virtual int GetMonthsInYear ( int year );
+               
+               // DONE!
+               public virtual int GetMonthsInYear ( int year )
+               {
+                       if( year < _MinYear || year > _MaxYear)
+                               throw new System.ArgumentException();
+
+                       return _MaxMonth;
+               }
+
+               // DONE!
                public abstract int GetMonthsInYear ( int year, int era );
-               public virtual int GetSecond ( DateTime time );
-               public virtual int GetWeekOfYear ( DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek );
+
+               // DONE!
+               public virtual int GetSecond ( DateTime time )
+               {
+                       return time.Second;
+               }
+
+               // DONE!
+               /// <summary>
+               /// Gets the week of the year that includes the date in the specified DateTime
+               /// </summary>
+               /// <param name="time"></param>
+               /// <param name="rule"></param>
+               /// <param name="firstDayOfWeek"></param>
+               /// <returns></returns>
+               /// <remarks>.NET beta 2 calculates this erroneous, but this one is ok(? I think...)</remarks>
+               public virtual int GetWeekOfYear ( DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek )
+               {
+                       if( firstDayOfWeek < DayOfWeek.Sunday || firstDayOfWeek > DayOfWeek.Saturday)
+                               throw new System.ArgumentOutOfRangeException();
+                       
+                       int week;
+                       int days = 0;
+                       
+                       int[] dim;
+                       if(this.IsLeapYear(time.Year))
+                               dim = _DaysInMonthLeap;
+                       else
+                               dim = _DaysInMonth;
+
+                       DateTime jan1 = new DateTime(time.Year, 1, 1);
+
+                       for( int i = 0; i < time.Month-1; i++)
+                               days += dim[i];
+                       days += time.Day;
+
+                       switch(rule)
+                       {
+                               case CalendarWeekRule.FirstDay:
+                                       while(jan1.DayOfWeek != firstDayOfWeek)
+                                       {
+                                               days--;
+                                               jan1 = jan1.AddTicks(_TicksPerDay);
+                                       }
+                                       break;
+                               case CalendarWeekRule.FirstFourDayWeek:
+                                       while(jan1.DayOfWeek < firstDayOfWeek)
+                                       {
+                                               days--;
+                                               jan1 = jan1.AddTicks(_TicksPerDay);
+                                       }
+                                       break;
+                               case CalendarWeekRule.FirstFullWeek:
+                                       if(jan1.DayOfWeek != firstDayOfWeek)
+                                       {
+                                               do
+                                               {
+                                                       days--;
+                                                       jan1 = jan1.AddTicks(_TicksPerDay);
+                                               }
+                                               while(jan1.DayOfWeek != firstDayOfWeek);
+                                       }
+                                       break;
+                               default:
+                                       throw new System.ArgumentOutOfRangeException();
+                       }
+
+                       if(days <= 0)
+                               week = GetWeekOfYear(new DateTime(time.Year-1,12,31), rule, firstDayOfWeek);
+                       else
+                               week = (--days / 7) + 1;
+                       
+                       return week;
+               }
+
+               // DONE!
                public abstract int GetYear ( DateTime time );
-               public virtual bool IsLeapDay ( int year, int month, int day );
+               
+               // DONE!
+               // TODO: verify this for the Calendar Class
+               public virtual bool IsLeapDay ( int year, int month, int day )
+               {
+                       int dim;
+
+                       if(day < _MinDay || month < _MinMonth || month > _MaxMonth)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if(this.IsLeapYear(year))
+                               dim = _DaysInMonthLeap[month-1];
+                       else
+                               dim = _DaysInMonth[month-1];
+
+                       if( day > dim)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if( month == 2 && day == 29)
+                               return true;
+                       
+                       return false;
+               }
+
+               // DONE!
                public abstract bool IsLeapDay ( int year, int month, int day, int era );
-               public virtual bool IsLeapMonth ( int year, int month );
+
+               // DONE!
+               public virtual bool IsLeapMonth ( int year, int month )
+               {
+                       if( year < _MinYear || year > _MaxYear || month < _MinMonth || month > _MaxMonth)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if(this.IsLeapYear(year))
+                       {
+                               return true;
+                       }
+                       else
+                               return false;
+               }
+               
+               // DONE!
                public abstract bool IsLeapMonth ( int year, int month, int era );
-               public virtual bool IsLeapYear ( int year );
+
+               public virtual bool IsLeapYear ( int year )
+               {
+                       if(year < _MinYear || year > _MaxYear )
+                               throw new System.ArgumentOutOfRangeException();
+                       if(year % 4 == 0) // TODO: verify this for the Calendar class!
+                               return true;
+                       return false;
+               }
+
+               // DONE!
                public abstract bool IsLeapYear ( int year, int era );
-               public virtual DateTime ToDateTime ( int year, int month, int day, int hour, int minute, int second, int millisecond );
+
+               // DONE!
+               public virtual DateTime ToDateTime ( int year, int month, int day, int hour, int minute, int second, int millisecond )
+               {
+                       int dim;
+                       dim = GetDaysInMonth(year,month);
+                       if( day < _MinDay || day > dim || 
+                               hour < _MinHour || hour > _MaxHour ||
+                               minute < _MinMinute || minute > _MaxMinute ||
+                               second < _MinSecond || second > _MaxSecond ||
+                               millisecond < _MinMillisecond || millisecond > _MaxMillisecond)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       return new DateTime(year,month,day,hour,minute,second,millisecond,this);
+               }
+
+               // DONE!
                public abstract DateTime ToDateTime ( int year, int month, int date, int hour, int minute, int second, int millisecond, int era );
-               public virtual int ToFourDigitYear ( int year );
+
+               // DONE!
+               public virtual int ToFourDigitYear ( int year )
+               {
+                       int i = year - ( _TwoDigitYearMax % 100 );
+                       if( year > 0 )
+                               return _TwoDigitYearMax - 100 + year;
+                       else
+                               return _TwoDigitYearMax + year;
+               }
        }
 }
-
diff --git a/mcs/class/corlib/System.Globalization/CalendarWeekRule.cs b/mcs/class/corlib/System.Globalization/CalendarWeekRule.cs
new file mode 100644 (file)
index 0000000..936a56e
--- /dev/null
@@ -0,0 +1,28 @@
+// ::MONO
+//
+// System.Globalization.CalendarWeekRule.cs
+//
+// Copyright (C) Wictor Wilén 2001 (wictor@iBizkit.se)
+//
+// Contributors: Wictor Wilén
+//
+// Revisions
+// 2001-09-14: First draft
+// 2001-09-15: First release
+
+using System;
+
+namespace System.Globalization
+{
+       /// <summary>
+       /// The System.Globalization.CalendarWeekRule enumeration
+       /// </summary>
+       public enum CalendarWeekRule
+       {
+               FirstDay = 0,
+               FirstFullWeek = 1,
+               FirstFourDayWeek = 2
+
+       }
+
+}
diff --git a/mcs/class/corlib/System.Globalization/GregorianCalendar.cs b/mcs/class/corlib/System.Globalization/GregorianCalendar.cs
new file mode 100644 (file)
index 0000000..852574b
--- /dev/null
@@ -0,0 +1,253 @@
+// ::MONO
+//
+// System.Globalization.GregorianCalendar.cs
+//
+// Copyright (C) Wictor Wilén 2001 (wictor@iBizkit.se)
+//
+// Contributors: Wictor Wilén
+//
+// Revisions
+// 2001-09-15: First draft
+//
+//
+// TODO: testing
+//
+//
+
+using System;
+
+namespace System.Globalization
+{
+
+       
+       /// <summary>
+       /// Represents the Gregorian calendar.
+       /// </summary>
+       /// <remarks>The Gregorian calendar recognizes two eras: B.C. (before Christ) or B.C.E. (before common era), and A.D. (Latin "Anno Domini", which means "in the year of the Lord") or C.E. (common era). This implementation of the GregorianCalendar class recognizes only the current era (A.D. or C.E.).</remarks>
+       // TODO: implement the BC era
+       public class GregorianCalendar : System.Globalization.Calendar
+       {
+               // private members
+               private GregorianCalendarTypes _CalendarType;
+
+
+               // Public Constants
+               public const int ADEra = 1;
+               
+               // Public Instance Constructors
+               // DONE!
+               public GregorianCalendar()
+               {
+                       _CalendarType = GregorianCalendarTypes.Localized;
+               }
+
+               // DONE!
+               public GregorianCalendar(GregorianCalendarTypes type)
+               {
+                       _CalendarType = type;
+               }
+               
+               // DONE!
+               public GregorianCalendarTypes CalendarType 
+               {
+                       get
+                       {
+                               return _CalendarType;
+                       } 
+                       set
+                       {
+                               _CalendarType = value;
+                       }
+               }
+
+               // Public Instance Properties
+               // DONE!
+               public override int[] Eras 
+               {
+                       get
+                       {
+                               return new int[] {1};
+                       }
+               }
+               // DONE!
+               public override int TwoDigitYearMax 
+               {
+                       get
+                       {
+                               return _TwoDigitYearMax;
+                       } 
+                       set
+                       {
+                               _TwoDigitYearMax = value;
+                       }
+               }
+
+               // Public Instance Methods
+               // DONE!
+               public override DateTime AddMonths ( DateTime time, int months )
+               {
+                       if(months < -120000 || months > 120000)
+                               throw new System.ArgumentOutOfRangeException();
+                       DateTime dt = new DateTime(time.Ticks);                 
+                       dt =  dt.AddMonths(months);
+                       return dt;
+                       
+               }
+               // DONE!
+               public override DateTime AddYears ( DateTime time, int years )
+               {
+                       DateTime dt = new DateTime(time.Ticks);
+                       return dt.AddYears(years);
+               }
+
+               // DONE!
+               public override int GetDayOfMonth ( DateTime time )
+               {
+                       return time.Day;
+               }
+
+               // DONE!
+               public override DayOfWeek GetDayOfWeek ( DateTime time )
+               {
+                       return time.DayOfWeek;
+               }
+
+               // DONE!
+               public override int GetDayOfYear ( DateTime time )
+               {
+                       return time.DayOfYear;
+               }
+               
+               // DONE!
+               public override int GetDaysInMonth ( int year, int month, int era )
+               {
+                       if(     year < _MinYear || year > _MaxYear || 
+                               month < _MinMonth || month > _MaxMonth )                                
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if( era != ADEra)
+                               throw new System.ArgumentException();
+
+                       if(this.IsLeapYear(year))
+                               return _DaysInMonthLeap[month];
+                       else
+                               return _DaysInMonth[month];
+               }
+               
+
+               // DONE!                
+               public override int GetDaysInYear ( int year, int era )
+               {
+                       if(year < _MinYear || year > _MaxYear)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if( era != ADEra)
+                               throw new System.ArgumentException();
+
+                       return this.GetDaysInYear(year);
+               }
+
+               // DONE!
+               public override int GetEra ( DateTime time )
+               {
+                       return ADEra;
+               }
+               // DONE!
+               public override int GetMonth ( DateTime time )
+               {
+                       return time.Month;
+               }
+
+               // DONE!                
+               public override int GetMonthsInYear ( int year, int era )
+               {
+                       if(year < _MinYear || year > _MaxYear || era != ADEra )
+                               throw new System.ArgumentOutOfRangeException();
+
+                       return _MaxMonth;
+               }
+               
+               // DONE!
+               public override int GetYear ( DateTime time )
+               {                       
+                       return time.Year;
+               }
+
+               // DONE!
+               public override bool IsLeapDay ( int year, int month, int day, int era )
+               {                       
+                       int dim;
+
+                       if(day < _MinDay || month < _MinMonth || month > _MaxMonth)
+                               throw new System.ArgumentException();
+
+                       if(this.IsLeapYear(year,era))
+                               dim = _DaysInMonthLeap[month-1];
+                       else
+                               dim = _DaysInMonth[month-1];
+
+                       if( day > dim)
+                               throw new System.ArgumentException();
+
+                       if( month == 2 && day == 29)
+                               return true;
+                       
+                       return false;
+               }
+               // DONE!
+               public override bool IsLeapMonth ( int year, int month )
+               {
+                       if( year < _MinYear || year > _MaxYear || month < _MinMonth || month > _MaxMonth)
+                               throw new System.ArgumentException();
+                       return false;   
+               }
+               // DONE!
+               public override bool IsLeapMonth ( int year, int month, int era )
+               {
+                       if( year < _MinYear || year > _MaxYear || month < _MinMonth || month > _MaxMonth || era != ADEra)
+                               throw new System.ArgumentException();
+                       return false;
+               }
+               
+               // DONE!
+               public override bool IsLeapYear ( int year, int era )
+               {
+                       if(year < _MinYear || year > _MaxYear || era != ADEra)
+                               throw new System.ArgumentOutOfRangeException();
+                       if( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) )
+                               return true;
+                       return false;
+               }
+               
+               // DONE!
+               public override DateTime ToDateTime ( int year, int month, int day, int hour, int minute, int second, int millisecond, int era )
+               {
+                       // INFO: year, era and month is checked by GetDaysInMonth()
+                       int dim;
+                       dim = GetDaysInMonth(year,month);
+                       if( day < _MinDay || day > dim || 
+                               hour < _MinHour || hour > _MaxHour ||
+                               minute < _MinMinute || minute > _MaxMinute ||
+                               second < _MinSecond || second > _MaxSecond ||
+                               millisecond < _MinMillisecond || millisecond > _MaxMillisecond)
+                               throw new System.ArgumentException();
+
+                       return new DateTime(year,month,day,hour,minute,second,millisecond,this);
+               }
+               
+               // DONE!
+               public override int ToFourDigitYear ( int year )
+               {
+                       int y = _TwoDigitYearMax % 100;
+                       if( year > y )
+                               y = _TwoDigitYearMax - y - 100 + year;
+                       else
+                               y = _TwoDigitYearMax - y + year;
+
+                       if( y < _MinYear || y > _MaxYear)
+                               throw new System.ArgumentException();
+                       return y;
+               }
+
+       }
+}
diff --git a/mcs/class/corlib/System.Globalization/JulianCalendar.cs b/mcs/class/corlib/System.Globalization/JulianCalendar.cs
new file mode 100644 (file)
index 0000000..f246d15
--- /dev/null
@@ -0,0 +1,230 @@
+// ::MONO
+//
+// System.Globalization.JulianCalendar.cs
+//
+// Copyright (C) Wictor Wilén 2001 (wictor@iBizkit.se)
+//
+// Contributors: 
+//
+// Revisions
+// 2001-09-14: First draft
+// 2001-09-15: First release
+//
+//
+// TODO: testing
+//
+//
+
+using System;
+
+namespace System.Globalization
+{
+
+       
+       /// <summary>
+       /// Summary description for JulianCalendar.
+       /// </summary>
+       public class JulianCalendar : System.Globalization.Calendar
+       {
+               
+               
+               // Public Static (Shared) Fields
+               // DONE!
+               public static int JulianEra
+               {
+                       get 
+                       {
+                               return 1;
+                       }
+               }
+
+               // Public Instance Constructors
+               // DONE!
+               public JulianCalendar()
+               {
+               }
+
+               // Public Instance Properties
+               // DONE!
+               public override int[] Eras 
+               {
+                       get
+                       {
+                               return new int[] {1};
+                       }
+               }
+               // DONE!
+               public override int TwoDigitYearMax 
+               {
+                       get
+                       {
+                               return _TwoDigitYearMax;
+                       } 
+                       set
+                       {
+                               _TwoDigitYearMax = value;
+                       }
+               }
+
+               // Public Instance Methods
+               // DONE!
+               public override DateTime AddMonths ( DateTime time, int months )
+               {
+                       if(months < -120000 || months > 120000)
+                               throw new System.ArgumentOutOfRangeException();
+                       DateTime dt = new DateTime(time.Ticks);                 
+                       dt =  dt.AddMonths(months);
+                       return dt;
+                       
+               }
+               // DONE!
+               public override DateTime AddYears ( DateTime time, int years )
+               {
+                       DateTime dt = new DateTime(time.Ticks);
+                       return dt.AddYears(years);
+               }
+
+               // DONE!
+               public override int GetDayOfMonth ( DateTime time )
+               {
+                       return time.Day;
+               }
+
+               // DONE!
+               public override DayOfWeek GetDayOfWeek ( DateTime time )
+               {
+                       return time.DayOfWeek;
+               }
+
+               // DONE!
+               public override int GetDayOfYear ( DateTime time )
+               {
+                       return time.DayOfYear;
+               }
+               
+               // DONE!
+               public override int GetDaysInMonth ( int year, int month, int era )
+               {
+                       if(     year < _MinYear || year > _MaxYear || 
+                               month < _MinMonth || month > _MaxMonth || 
+                               era != JulianEra)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if(this.IsLeapYear(year))
+                               return _DaysInMonthLeap[month];
+                       else
+                               return _DaysInMonth[month];
+               }
+               
+
+               // DONE!                
+               public override int GetDaysInYear ( int year, int era )
+               {
+                       if(year < _MinYear || year > _MaxYear || era != JulianEra)
+                               throw new System.ArgumentOutOfRangeException();
+                       return this.GetDaysInYear(year);
+               }
+
+               // DONE!
+               public override int GetEra ( DateTime time )
+               {
+                       return JulianEra;
+               }
+               // DONE!
+               public override int GetMonth ( DateTime time )
+               {
+                       return time.Month;
+               }
+
+               // DONE!                
+               public override int GetMonthsInYear ( int year, int era )
+               {
+                       if(year < _MinYear || year > _MaxYear || era != JulianEra)
+                               throw new System.ArgumentOutOfRangeException();
+                       return _MaxMonth;
+               }
+               
+               // DONE!
+               public override int GetYear ( DateTime time )
+               {                       
+                       return time.Year;
+               }
+
+               // DONE!
+               public override bool IsLeapDay ( int year, int month, int day, int era )
+               {                       
+                       int dim;
+
+                       if(day < _MinDay || month < _MinMonth || month > _MaxMonth)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if(this.IsLeapYear(year,era))
+                               dim = _DaysInMonthLeap[month-1];
+                       else
+                               dim = _DaysInMonth[month-1];
+
+                       if( day > dim)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       if( month == 2 && day == 29)
+                               return true;
+                       
+                       return false;
+               }
+               // DONE!
+               public override bool IsLeapMonth ( int year, int month )
+               {
+                       if( year < _MinYear || year > _MaxYear || month < _MinMonth || month > _MaxMonth)
+                               throw new System.ArgumentException();
+                       return false;   
+               }
+               // DONE!
+               public override bool IsLeapMonth ( int year, int month, int era )
+               {
+                       if( year < _MinYear || year > _MaxYear || month < _MinMonth || month > _MaxMonth || era != JulianEra)
+                               throw new System.ArgumentException();
+                       return false;
+               }
+               
+               // DONE!
+               public override bool IsLeapYear ( int year, int era )
+               {
+                       if(year < _MinYear || year > _MaxYear || era != JulianEra)
+                               throw new System.ArgumentOutOfRangeException();
+                       if(year % 4 == 0)
+                               return true;
+                       return false;
+               }
+               
+               // DONE!
+               public override DateTime ToDateTime ( int year, int month, int day, int hour, int minute, int second, int millisecond, int era )
+               {
+                       // INFO: year, era and month is checked by GetDaysInMonth()
+                       int dim;
+                       dim = GetDaysInMonth(year,month);
+                       if( day < _MinDay || day > dim || 
+                               hour < _MinHour || hour > _MaxHour ||
+                               minute < _MinMinute || minute > _MaxMinute ||
+                               second < _MinSecond || second > _MaxSecond ||
+                               millisecond < _MinMillisecond || millisecond > _MaxMillisecond)
+                               throw new System.ArgumentOutOfRangeException();
+
+                       return new DateTime(year,month,day,hour,minute,second,millisecond,this);
+               }
+               
+               // DONE!
+               public override int ToFourDigitYear ( int year )
+               {
+                       int y = _TwoDigitYearMax % 100;
+                       if( year > y )
+                               y = _TwoDigitYearMax - y - 100 + year;
+                       else
+                               y = _TwoDigitYearMax - y + year;
+
+                       if( y < _MinYear || y > _MaxYear)
+                               throw new System.ArgumentException();
+                       return y;
+               }
+
+       }
+}