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