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