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