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