2005-11-29 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / corlib / System.Globalization / TaiwanCalendar.cs
1 // TaiwanCalendar.cs
2 //
3 // (C) Ulrich Kunitz 2002
4 //
5
6 //
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 namespace System.Globalization {
30
31 using System;
32
33 /// <summary>
34 /// This is the Japanese calendar. It differs from the Gregorian calendar
35 /// only in the years.
36 /// </summary>
37 /// <remarks>
38 /// <para>The Japanese calendar support a single era starting at January 1,
39 /// 1912</para>
40 /// <para>The implementation uses the
41 /// <see cref="N:CalendricalCalculations"/> namespace.
42 /// </para>
43 /// </remarks>
44 #if NET_2_0
45 [System.Runtime.InteropServices.ComVisible(true)]
46 #endif
47 [Serializable]
48 [MonoTODO ("Fix serialization compatibility with MS.NET")]
49 public class TaiwanCalendar : Calendar {
50         /// <summary>
51         /// Static protected field storing the
52         /// <see cref="T:CalendricalCalculations.GregorianEraHandler"/>.
53         /// </summary>
54         internal static readonly CCGregorianEraHandler M_EraHandler;
55
56         /// <summary>
57         /// Static constructor, who creates and initializes
58         /// <see cref="F:M_EraHandler"/>.
59         /// </summary>
60         static TaiwanCalendar() {
61                 M_EraHandler = new CCGregorianEraHandler();
62                 M_EraHandler.appendEra(1,
63                         CCGregorianCalendar.fixed_from_dmy(1, 1, 1912));
64         }
65
66         /// <summary>
67         /// Default constructor.
68         /// </summary>
69         public TaiwanCalendar() {
70                 M_AbbrEraNames = new string[] {"T.C.E."};
71                 M_EraNames =  new string[] {"Taiwan current era"};
72         }
73
74         /// <value>Overridden. Gives the eras supported by the
75         /// calendar as an array of integers.
76         /// </value>
77         public override int[] Eras {
78                 get {
79                         return (int[])M_EraHandler.Eras.Clone();
80                 }
81         }
82
83         int twoDigitYearMax = 99;
84         
85         public override int TwoDigitYearMax 
86         {
87                 get {
88                         return twoDigitYearMax;
89                 }
90                 set {
91                         CheckReadOnly ();
92                         M_ArgumentInRange ("value", value, 100, M_MaxYear);
93
94                         twoDigitYearMax = value;
95                 }
96         }
97
98         /// <summary>
99         /// A protected member checking a
100         /// <see cref="T:System.DateTime"/> value.
101         /// </summary>
102         /// <param name="time">The
103         /// <see cref="T:System.DateTime"/>
104         /// to check.
105         /// </param>
106         /// <exception cref="T:System.ArgumentOutOfRangeException">
107         /// The exception is thrown if the
108         /// <see cref="T:System.DateTime"/> parameter is outside all
109         /// supported eras.
110         /// </exception>
111         internal void M_CheckDateTime(DateTime time) {
112                 M_EraHandler.CheckDateTime(time);
113         }
114
115         /// <summary>
116         /// A protected method checking the era number.
117         /// </summary>
118         /// <param name="era">The era number as reference. It is set
119         /// to <see cref="F:CurrentEra"/>, if the input value is 0.</param>
120         /// <exception name="T:System.ArgumentException">
121         /// The exception is thrown if the era is not supported by the class.
122         /// </exception>
123         internal void M_CheckEra(ref int era) {
124                 if (era == CurrentEra)
125                         era = 1;
126                 if (!M_EraHandler.ValidEra(era))
127                         throw new ArgumentException("Era value was not valid.");
128         }
129
130         /// <summary>
131         /// A protected method checking calendar year and the era number.
132         /// </summary>
133         /// <param name="year">An integer representing the calendar year.
134         /// </param>
135         /// <param name="era">The era number as reference.</param>
136         /// <exception name="T:System.ArgumentException">
137         /// The exception is thrown if the era is not supported by the class.
138         /// </exception>
139         /// <exception cref="T:System.ArgumentOutOfRangeException">
140         /// The exception is thrown if the calendar year is outside of
141         /// the supported range.
142         /// </exception>
143         internal int M_CheckYEG(int year, ref int era) {
144                 M_CheckEra(ref era);
145                 return M_EraHandler.GregorianYear(year, era);
146         }
147
148         /// <summary>
149         /// Checks whether the year is the era is valid, if era = CurrentEra
150         /// the right value is set.
151         /// </summary>
152         /// <param name="year">The year to check.</param>
153         /// <param name="era">The era to check.</Param>
154         /// <exception cref="T:ArgumentOutOfRangeException">
155         /// The exception will be thrown, if the year is not valid.
156         /// </exception>
157         internal override void M_CheckYE(int year, ref int era) {
158                 M_CheckYEG(year, ref era);
159         }
160
161         /// <summary>
162         /// A protected method checking the calendar year, month, and
163         /// era number.
164         /// </summary>
165         /// <param name="year">An integer representing the calendar year.
166         /// </param>
167         /// <param name="month">An integer giving the calendar month.
168         /// </param>
169         /// <param name="era">The era number as reference.</param>
170         /// <exception name="T:System.ArgumentException">
171         /// The exception is thrown if the era is not supported by the class.
172         /// </exception>
173         /// <exception cref="T:System.ArgumentOutOfRangeException">
174         /// The exception is thrown if the calendar year or month is
175         /// outside of the supported range.
176         /// </exception>
177         internal int M_CheckYMEG(int year, int month, ref int era) {
178                 int gregorianYear = M_CheckYEG(year, ref era);
179                 if (month < 1 || month > 12)
180                         throw new ArgumentOutOfRangeException("month",
181                                 "Month must be between one and twelve.");
182                 return gregorianYear;
183         }
184
185         /// <summary>
186         /// A protected method checking the calendar day, month, and year
187         /// and the era number.
188         /// </summary>
189         /// <param name="year">An integer representing the calendar year.
190         /// </param>
191         /// <param name="month">An integer giving the calendar month.
192         /// </param>
193         /// <param name="day">An integer giving the calendar day.
194         /// </param>
195         /// <param name="era">The era number as reference.</param>
196         /// <exception name="T:System.ArgumentException">
197         /// The exception is thrown if the era is not supported by the class.
198         /// </exception>
199         /// <exception cref="T:System.ArgumentOutOfRangeException">
200         /// The exception is thrown if the calendar year, month, or day is
201         /// outside of the supported range.
202         /// </exception>
203         internal int M_CheckYMDEG(int year, int month, int day, ref int era)
204         {
205                 int gregorianYear = M_CheckYMEG(year, month, ref era);
206                 M_ArgumentInRange("day", day, 1,
207                         GetDaysInMonth(year, month, era));
208                 return gregorianYear;
209         }
210
211 #if false
212
213         // Ifdefed out because this is not on the .NET Framework
214         
215         /// <summary>
216         /// Overridden. Adds days to a given date.
217         /// </summary>
218         /// <param name="time">The
219         /// <see cref="T:System.DateTime"/> to which to add
220         /// days.
221         /// </param>
222         /// <param name="days">The number of days to add.</param>
223         /// <returns>A new <see cref="T:System.DateTime"/> value, that
224         /// results from adding <paramref name="days"/> to the specified
225         /// DateTime.</returns>
226         /// <exception cref="T:System.ArgumentOutOfRangeException">
227         /// The exception is thrown if the
228         /// <see cref="T:System.DateTime"/> return value is outside all
229         /// supported eras.
230         /// </exception>
231         public override DateTime AddDays(DateTime time, int days) {
232                 DateTime t = base.AddDays(time, days);
233                 M_CheckDateTime(t);
234                 return t;
235         }
236
237         /// <summary>
238         /// Overridden. Adds hours to a given date.
239         /// </summary>
240         /// <param name="time">The
241         /// <see cref="T:System.DateTime"/> to which to add
242         /// hours.
243         /// </param>
244         /// <param name="hours">The number of hours to add.</param>
245         /// <returns>A new <see cref="T:System.DateTime"/> value, that
246         /// results from adding <paramref name="hours"/> to the specified
247         /// DateTime.</returns>
248         /// <exception cref="T:System.ArgumentOutOfRangeException">
249         /// The exception is thrown if the
250         /// <see cref="T:System.DateTime"/> return value is outside all
251         /// supported eras.
252         /// </exception>
253         public override DateTime AddHours(DateTime time, int hours) {
254                 DateTime t = base.AddHours(time, hours);
255                 M_CheckDateTime(t);
256                 return t;
257         }
258
259         /// <summary>
260         /// Overridden. Adds milliseconds to a given date.
261         /// </summary>
262         /// <param name="time">The
263         /// <see cref="T:System.DateTime"/> to which to add
264         /// milliseconds.
265         /// </param>
266         /// <param name="milliseconds">The number of milliseconds given as
267         /// double to add. Keep in mind the 100 nanosecond resolution of 
268         /// <see cref="T:System.DateTime"/>.
269         /// </param>
270         /// <returns>A new <see cref="T:System.DateTime"/> value, that
271         /// results from adding <paramref name="milliseconds"/> to the specified
272         /// DateTime.</returns>
273         /// <exception cref="T:System.ArgumentOutOfRangeException">
274         /// The exception is thrown if the
275         /// <see cref="T:System.DateTime"/> return value is outside all
276         /// supported eras.
277         /// </exception>
278         public override DateTime AddMilliseconds(DateTime time,
279                 double milliseconds)
280         {
281                 DateTime t = base.AddMilliseconds(time, milliseconds);
282                 M_CheckDateTime(t);
283                 return t;
284         }
285
286         /// <summary>
287         /// Overridden. Adds minutes to a given date.
288         /// </summary>
289         /// <param name="time">The
290         /// <see cref="T:System.DateTime"/> to which to add
291         /// minutes.
292         /// </param>
293         /// <param name="minutes">The number of minutes to add.</param>
294         /// <returns>A new <see cref="T:System.DateTime"/> value, that
295         /// results from adding <paramref name="minutes"/> to the specified
296         /// DateTime.</returns>
297         /// <exception cref="T:System.ArgumentOutOfRangeException">
298         /// The exception is thrown if the
299         /// <see cref="T:System.DateTime"/> return value is outside all
300         /// supported eras.
301         /// </exception>
302         public override DateTime AddMinutes(DateTime time, int minutes) {
303                 DateTime t = base.AddMinutes(time, minutes);
304                 M_CheckDateTime(t);
305                 return t;
306         }
307
308         /// <summary>
309         /// Overridden. Adds seconds to a given date.
310         /// </summary>
311         /// <param name="time">The
312         /// <see cref="T:System.DateTime"/> to which to add
313         /// seconds.
314         /// </param>
315         /// <param name="seconds">The number of seconds to add.</param>
316         /// <returns>A new <see cref="T:System.DateTime"/> value, that
317         /// results from adding <paramref name="seconds"/> to the specified
318         /// DateTime.</returns>
319         /// <exception cref="T:System.ArgumentOutOfRangeException">
320         /// The exception is thrown if the
321         /// <see cref="T:System.DateTime"/> return value is outside all
322         /// supported eras.
323         /// </exception>
324         public override DateTime AddSeconds(DateTime time, int seconds) {
325                 DateTime t = base.AddSeconds(time, seconds);
326                 M_CheckDateTime(t);
327                 return t;
328         }
329
330
331         /// <summary>
332         /// Overridden. Adds weeks to a given date.
333         /// </summary>
334         /// <param name="time">The
335         /// <see cref="T:System.DateTime"/> to which to add
336         /// weeks.
337         /// </param>
338         /// <param name="weeks">The number of weeks to add.</param>
339         /// <returns>A new <see cref="T:System.DateTime"/> value, that
340         /// results from adding <paramref name="weeks"/> to the specified
341         /// DateTime.</returns>
342         /// <exception cref="T:System.ArgumentOutOfRangeException">
343         /// The exception is thrown if the
344         /// <see cref="T:System.DateTime"/> return value is outside all
345         /// supported eras.
346         /// </exception>
347         public override DateTime AddWeeks(DateTime time, int weeks) {
348                 DateTime t = base.AddWeeks(time, weeks);
349                 M_CheckDateTime(t);
350                 return t;
351         }
352
353         /// <summary>
354         /// Overridden. Gives the hour of the specified time.
355         /// </summary>
356         /// <param name="time">The
357         /// <see cref="T:System.DateTime"/> that specifies the
358         /// time.
359         /// </param>
360         /// <returns>An integer that gives the hour of the specified time,
361         /// starting with 0.</returns>
362         /// <exception cref="T:System.ArgumentOutOfRangeException">
363         /// The exception is thrown if the
364         /// <see cref="T:System.DateTime"/> parameter is outside all
365         /// supported eras.
366         /// </exception>
367         public override int GetHour(DateTime time) {
368                 M_CheckDateTime(time);
369                 return base.GetHour(time);
370         }
371
372         /// <summary>
373         /// Overridden. Gives the milliseconds in the current second
374         /// of the specified time.
375         /// </summary>
376         /// <param name="time">The
377         /// <see cref="T:System.DateTime"/> that specifies the
378         /// time.
379         /// </param>
380         /// <returns>An integer that gives the milliseconds in the seconds
381         /// of the specified time, starting with 0.</returns>
382         /// <exception cref="T:System.ArgumentOutOfRangeException">
383         /// The exception is thrown if the
384         /// <see cref="T:System.DateTime"/> parameter is outside all
385         /// supported eras.
386         /// </exception>
387         public override double GetMilliseconds(DateTime time) {
388                 M_CheckDateTime(time);
389                 return base.GetMilliseconds(time);
390         }
391
392         /// <summary>
393         /// Overridden. Gives the minute of the specified time.
394         /// </summary>
395         /// <param name="time">The
396         /// <see cref="T:System.DateTime"/> that specifies the
397         /// time.
398         /// </param>
399         /// <returns>An integer that gives the minute of the specified time,
400         /// starting with 0.</returns>
401         /// <exception cref="T:System.ArgumentOutOfRangeException">
402         /// The exception is thrown if the
403         /// <see cref="T:System.DateTime"/> parameter is outside all
404         /// supported eras.
405         /// </exception>
406         public override int GetMinute(DateTime time) {
407                 M_CheckDateTime(time);
408                 return base.GetMinute(time);
409         }
410
411         /// <summary>
412         /// Overridden. Gives the second of the specified time.
413         /// </summary>
414         /// <param name="time">The
415         /// <see cref="T:System.DateTime"/> that specifies the
416         /// time.
417         /// </param>
418         /// <returns>An integer that gives the second of the specified time,
419         /// starting with 0.</returns>
420         /// <exception cref="T:System.ArgumentOutOfRangeException">
421         /// The exception is thrown if the
422         /// <see cref="T:System.DateTime"/> parameter is outside all
423         /// supported eras.
424         /// </exception>
425         public override int GetSecond(DateTime time) {
426                 M_CheckDateTime(time);
427                 return base.GetMinute(time);
428         }
429 #endif
430         
431         /// <summary>
432         /// Overrideden. Adds months to a given date.
433         /// </summary>
434         /// <param name="time">The
435         /// <see cref="T:System.DateTime"/> to which to add
436         /// months.
437         /// </param>
438         /// <param name="months">The number of months to add.</param>
439         /// <returns>A new <see cref="T:System.DateTime"/> value, that
440         /// results from adding <paramref name="months"/> to the specified
441         /// DateTime.</returns>
442         /// <exception cref="T:System.ArgumentOutOfRangeException">
443         /// The exception is thrown if
444         /// <see cref="T:System.DateTime"/> return value is outside all
445         /// supported eras.
446         /// </exception>
447         public override DateTime AddMonths(DateTime time, int months) {
448                 DateTime t = CCGregorianCalendar.AddMonths(time, months);
449                 M_CheckDateTime(t);
450                 return t;
451         }
452
453         /// <summary>
454         /// Overridden. Adds years to a given date.
455         /// </summary>
456         /// <param name="time">The
457         /// <see cref="T:System.DateTime"/> to which to add
458         /// years.
459         /// </param>
460         /// <param name="years">The number of years to add.</param>
461         /// <returns>A new <see cref="T:System.DateTime"/> value, that
462         /// results from adding <paramref name="years"/> to the specified
463         /// DateTime.</returns>
464         /// <exception cref="T:System.ArgumentOutOfRangeException">
465         /// The exception is thrown if
466         /// <see cref="T:System.DateTime"/> return value is outside all
467         /// supported eras.
468         /// </exception>
469         public override DateTime AddYears(DateTime time, int years) {
470                 DateTime t = CCGregorianCalendar.AddYears(time, years);
471                 M_CheckDateTime(t);
472                 return t;
473         }
474                 
475         /// <summary>
476         /// Overriden. Gets the day of the month from
477         /// <paramref name="time"/>.
478         /// </summary>
479         /// <param name="time">The
480         /// <see cref="T:System.DateTime"/> that specifies a
481         /// date.
482         /// </param>
483         /// <returns>An integer giving the day of months, starting with 1.
484         /// </returns>
485         /// <exception cref="T:System.ArgumentOutOfRangeException">
486         /// The exception is thrown if the
487         /// <see cref="T:System.DateTime"/> parameter is outside all
488         /// supported eras.
489         /// </exception>
490         public override int GetDayOfMonth(DateTime time) {
491                 M_CheckDateTime(time);
492                 return CCGregorianCalendar.GetDayOfMonth(time);
493         }
494
495         /// <summary>
496         /// Overriden. Gets the day of the week from the specified date.
497         /// </summary>
498         /// <param name="time">The
499         /// <see cref="T:System.DateTime"/> that specifies a
500         /// date.
501         /// </param>
502         /// <returns>An integer giving the day of months, starting with 1.
503         /// </returns>
504         /// <exception cref="T:System.ArgumentOutOfRangeException">
505         /// The exception is thrown if the
506         /// <see cref="T:System.DateTime"/> parameter is outside all
507         /// supported eras.
508         /// </exception>
509         public override DayOfWeek GetDayOfWeek(DateTime time) {
510                 M_CheckDateTime(time);
511                 int rd = CCFixed.FromDateTime(time);
512                 return (DayOfWeek)CCFixed.day_of_week(rd);
513         }
514
515         /// <summary>
516         /// Overridden. Gives the number of the day in the year.
517         /// </summary>
518         /// <param name="time">The
519         /// <see cref="T:System.DateTime"/> that specifies a
520         /// date.
521         /// </param>
522         /// <returns>An integer representing the day of the year,
523         /// starting with 1.</returns>
524         /// <exception cref="T:System.ArgumentOutOfRangeException">
525         /// The exception is thrown if the
526         /// <see cref="T:System.DateTime"/> parameter is outside all
527         /// supported eras.
528         /// </exception>
529         public override int GetDayOfYear(DateTime time) {
530                 M_CheckDateTime(time);
531                 return CCGregorianCalendar.GetDayOfYear(time);
532         }
533
534         /// <summary>
535         /// Overridden. Gives the number of days in the specified month
536         /// of the given year and era.
537         /// </summary>
538         /// <param name="year">An integer that gives the year.
539         /// </param>
540         /// <param name="month">An integer that gives the month, starting
541         /// with 1.</param>
542         /// <param name="era">An integer that gives the era of the specified
543         /// year.</param>
544         /// <returns>An integer that gives the number of days of the
545         /// specified month.</returns>
546         /// <exception cref="T:System.ArgumentOutOfRangeException">
547         /// The exception is thrown, if <paramref name="month"/>,
548         /// <paramref name="year"/> ,or <paramref name="era"/> is outside
549         /// the allowed range.
550         /// </exception>
551         public override int GetDaysInMonth(int year, int month, int era) {
552                 int gregorianYear = M_CheckYMEG(year, month, ref era);
553                 return CCGregorianCalendar.GetDaysInMonth(gregorianYear, month);
554         }
555
556         /// <summary>
557         /// Overridden. Gives the number of days of the specified
558         /// year of the given era. 
559         /// </summary>
560         /// <param name="year">An integer that specifies the year. 
561         /// </param>
562         /// <param name="era">An ineger that specifies the era.
563         /// </param>
564         /// <returns>An integer that gives the number of days of the
565         /// specified year.</returns>
566         /// <exception cref="T:System.ArgumentOutOfRangeExceiption">
567         /// The exception is thrown, if
568         /// <paramref name="year"/> or <paramref name="era"/> are outside the
569         /// allowed range.
570         /// </exception>
571         public override int GetDaysInYear(int year, int era) {
572                 int gregorianYear = M_CheckYEG(year, ref era);
573                 return CCGregorianCalendar.GetDaysInYear(gregorianYear);
574         }
575                 
576
577         /// <summary>
578         /// Overridden. Gives the era of the specified date.
579         /// </summary>
580         /// <param name="time">The
581         /// <see cref="T:System.DateTime"/> that specifies a
582         /// date.
583         /// </param>
584         /// <returns>An integer representing the era of the calendar.
585         /// </returns>
586         /// <exception cref="T:System.ArgumentOutOfRangeException">
587         /// The exception is thrown if the
588         /// <see cref="T:System.DateTime"/> parameter is outside all
589         /// supported eras.
590         /// </exception>
591         public override int GetEra(DateTime time) {
592                 // M_CheckDateTime not needed, because EraYear does the
593                 // right thing.
594                 int rd = CCFixed.FromDateTime(time);
595                 int era;
596                 M_EraHandler.EraYear(out era, rd);
597                 return era;
598         }
599
600         /// <summary>
601         /// Overridden. Gives the number of the month of the specified
602         /// date.
603         /// </summary>
604         /// <param name="time">The
605         /// <see cref="T:System.DateTime"/> that specifies a
606         /// date.
607         /// </param>
608         /// <returns>An integer representing the month, 
609         /// starting with 1.</returns>
610         /// <exception cref="T:System.ArgumentOutOfRangeException">
611         /// The exception is thrown if the
612         /// <see cref="T:System.DateTime"/> parameter is outside all
613         /// supported eras.
614         /// </exception>
615         public override int GetMonth(DateTime time) {
616                 M_CheckDateTime(time);
617                 return CCGregorianCalendar.GetMonth(time);
618         }
619
620         /// <summary>
621         /// Overridden. Gives the number of months in the specified year 
622         /// and era.
623         /// </summary>
624         /// <param name="year">An integer that specifies the year.
625         /// </param>
626         /// <param name="era">An integer that specifies the era.
627         /// </param>
628         /// <returns>An integer that gives the number of the months in the
629         /// specified year.</returns>
630         /// <exception cref="T:System.ArgumentOutOfRangeException">
631         /// The exception is thrown, if the year or the era are not valid.
632         /// </exception>
633         public override int GetMonthsInYear(int year, int era) {
634                 M_CheckYEG(year, ref era);
635                 return 12;
636         }
637
638         /// <summary>
639         /// Overridden. Gives the number of the year of the specified
640         /// date.
641         /// </summary>
642         /// <param name="time">The
643         /// <see cref="T:System.DateTime"/> that specifies a
644         /// date.
645         /// </param>
646         /// <returns>An integer representing the year, 
647         /// starting with 1.</returns>
648         /// <exception cref="T:System.ArgumentOutOfRangeException">
649         /// The exception is thrown if the
650         /// <see cref="T:System.DateTime"/> parameter is outside all
651         /// supported eras.
652         /// </exception>
653         public override int GetYear(DateTime time) {
654                 // M_CheckDateTime not needed, because EraYeat does the
655                 // right thing.
656                 int rd = CCFixed.FromDateTime(time);
657                 int era;
658                 return M_EraHandler.EraYear(out era, rd);
659         }
660
661         /// <summary>
662         /// Overridden. Tells whether the given day 
663         /// is a leap day.
664         /// </summary>
665         /// <param name="year">An integer that specifies the year in the
666         /// given era.
667         /// </param>
668         /// <param name="month">An integer that specifies the month.
669         /// </param>
670         /// <param name="day">An integer that specifies the day.
671         /// </param>
672         /// <param name="era">An integer that specifies the era.
673         /// </param>
674         /// <returns>A boolean that tells whether the given day is a leap
675         /// day.
676         /// </returns>
677         /// <exception cref="T:System.ArgumentOutOfRangeException">
678         /// The exception is thrown, if the year, month, day, or era is not
679         /// valid.
680         /// </exception>
681         public override bool IsLeapDay(int year, int month, int day, int era)
682         {
683                 int gregorianYear = M_CheckYMDEG(year, month, day, ref era);
684                 return CCGregorianCalendar.IsLeapDay(gregorianYear, month, day);
685         }
686
687         /// <summary>
688         /// Overridden. Tells whether the given month 
689         /// is a leap month.
690         /// </summary>
691         /// <param name="year">An integer that specifies the year in the
692         /// given era.
693         /// </param>
694         /// <param name="month">An integer that specifies the month.
695         /// </param>
696         /// <param name="era">An integer that specifies the era.
697         /// </param>
698         /// <returns>A boolean that tells whether the given month is a leap
699         /// month.
700         /// </returns>
701         /// <exception cref="T:System.ArgumentOutOfRangeException">
702         /// The exception is thrown, if the year, month, or era is not
703         /// valid.
704         /// </exception>
705         public override bool IsLeapMonth(int year, int month, int era) {
706                 M_CheckYMEG(year, month, ref era);
707                 return false;
708         }
709
710         /// <summary>
711         /// Overridden. Tells whether the given year
712         /// is a leap year.
713         /// </summary>
714         /// <param name="year">An integer that specifies the year in the
715         /// given era.
716         /// </param>
717         /// <param name="era">An integer that specifies the era.
718         /// </param>
719         /// <returns>A boolean that tells whether the given year is a leap
720         /// year.
721         /// </returns>
722         /// <exception cref="T:System.ArgumentOutOfRangeException">
723         /// The exception is thrown, if the year or era is not
724         /// valid.
725         /// </exception>
726         public override bool IsLeapYear(int year, int era) {
727                 int gregorianYear = M_CheckYEG(year, ref era);
728                 return CCGregorianCalendar.is_leap_year(gregorianYear);
729         }
730
731         /// <summary>
732         /// Overridden. Creates the
733         /// <see cref="T:System.DateTime"/> from the parameters.
734         /// </summary>
735         /// <param name="year">An integer that gives the year in the
736         /// <paramref name="era"/>.
737         /// </param>
738         /// <param name="month">An integer that specifies the month.
739         /// </param>
740         /// <param name="day">An integer that specifies the day.
741         /// </param>
742         /// <param name="hour">An integer that specifies the hour.
743         /// </param>
744         /// <param name="minute">An integer that specifies the minute.
745         /// </param>
746         /// <param name="second">An integer that gives the second.
747         /// </param>
748         /// <param name="milliseconds">An integer that gives the
749         /// milliseconds.
750         /// </param>
751         /// <param name="era">An integer that specifies the era.
752         /// </param>
753         /// <returns>A
754         /// <see cref="T:system.DateTime"/> representig the date and time.
755         /// </returns>
756         /// <exception cref="T:System.ArgumentOutOfRangeException">
757         /// The exception is thrown, if at least one of the parameters
758         /// is out of range.
759         /// </exception>
760         public override DateTime ToDateTime(int year, int month, int day,
761                 int hour, int minute, int second, int milliseconds,
762                 int era)
763         {
764                 int gregorianYear = M_CheckYMDEG(year, month, day, ref era);
765                 M_CheckHMSM(hour, minute, second, milliseconds);
766                 return CCGregorianCalendar.ToDateTime(
767                         gregorianYear, month, day,
768                         hour, minute, second, milliseconds);
769         }
770
771         /// <summary>
772         /// This functions returns simply the year for the Taiwan calendar.
773         /// </summary>
774         /// <param name="year">An integer that gives the year.
775         /// </param>
776         /// <returns>The same argument as the year.
777         /// </returns>
778         /// <exception cref="T:System.ArgumentOutOfRangeException">
779         /// The exception is thrown if the year is negative or the resulting 
780         /// year is invalid.
781         /// </exception>
782         public override int ToFourDigitYear(int year) {
783                 if (year < 0)
784                         throw new ArgumentOutOfRangeException(
785                                 "year", "Non-negative number required.");
786                 int era = CurrentEra;
787                 M_CheckYE(year, ref era);
788                 return year;
789         }
790 #if NET_2_0
791         public override CalendarAlgorithmType AlgorithmType {
792                 get {
793                         return CalendarAlgorithmType.SolarCalendar;
794                 }
795         }
796
797         static DateTime TaiwanMin = new DateTime (1912, 1, 1, 0, 0, 0);
798         static DateTime TaiwanMax = new DateTime (9999, 12, 31, 11, 59, 59);
799                 
800         public override DateTime MinSupportedDateTime {
801                 get {
802                         return TaiwanMin;
803                 }
804         }
805
806         public override DateTime MaxSupportedDateTime {
807                 get {
808                         return TaiwanMax;
809                 }
810         }
811 #endif
812         
813 } // class TaiwanCalendar
814         
815 } // namespace System.Globalization