3 // (C) Ulrich Kunitz 2002
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
29 namespace System.Globalization {
35 /// This is the Hebrew calendar.
38 /// <para>The Hebrew calendar supports only years between 5343 A.M. and
39 /// 6000 A.M. This has been done to be compatible with .NET.
41 /// <para>The implementation uses the
42 /// <see cref="N:CalendricalCalculations"/> namespace.
46 [MonoTODO ("Fix serialization compatibility with MS.NET")]
47 public class HebrewCalendar : Calendar {
51 public HebrewCalendar() {
52 M_AbbrEraNames = new string[] {"A.M."};
53 M_EraNames = new string[] {"Anno Mundi"};
54 if (M_TwoDigitYearMax == 99)
55 M_TwoDigitYearMax = 5790;
59 /// The era number for the Anno Mundi (A.M.) era, called
62 public static readonly int HebrewEra = 1;
66 /// <see cref="T:System.DateTime"/> ticks for first day of year
69 internal const long M_MinTicks = 499147488000000000L;
72 /// <see cref="T:System.DateTime"/> ticks for the last day of year
75 internal const long M_MaxTicks = 706783967999999999L;
77 /// The minimum year in the A.M. era supported.
79 internal const int M_MinYear = 5343;
81 /// The maximum year supported in the A.M. era.
83 internal override int M_MaxYear {
87 /// <value>Overridden. Gives the eras supported by the Gregorian
88 /// calendar as an array of integers.
90 public override int[] Eras {
92 return new int[] { HebrewEra };
96 int twoDigitYearMax = 5790;
98 public override int TwoDigitYearMax
101 return twoDigitYearMax;
105 M_ArgumentInRange ("value", value, M_MinYear, M_MaxYear);
107 twoDigitYearMax = value;
112 /// A protected member checking a
113 /// <see cref="T:System.DateTime"/> value.
115 /// <param name="time">The
116 /// <see cref="T:System.DateTime"/>
119 /// <exception cref="T:System.ArgumentOutOfRangeException">
120 /// The exception is thrown if the
121 /// <see cref="T:System.DateTime"/> parameter is not in the years
122 /// between 5343 A.M. and 6000 A.M., inclusive.
124 internal void M_CheckDateTime(DateTime time) {
125 if (time.Ticks < M_MinTicks || time.Ticks > M_MaxTicks)
126 throw new ArgumentOutOfRangeException(
128 "Only hebrew years between 5343 and 6000," +
129 " inclusive, are supported.");
133 /// A protected method checking the era number.
135 /// <param name="era">The era number.</param>
136 /// <exception name="T:System.ArgumentException">
137 /// The exception is thrown if the era is not equal
138 /// <see cref="F:HebrewEra"/>.
140 internal void M_CheckEra(ref int era) {
141 if (era == CurrentEra)
143 if (era != HebrewEra)
144 throw new ArgumentException("Era value was not valid.");
148 /// A protected method checking calendar year and the era number.
150 /// <param name="year">An integer representing the calendar year.
152 /// <param name="era">The era number.</param>
153 /// <exception cref="T:System.ArgumentException">
154 /// The exception is thrown if the era is not equal
155 /// <see cref="F:HebrewEra"/>.
157 /// <exception cref="T:System.ArgumentOutOfRangeException">
158 /// The exception is thrown if the calendar year is outside of
159 /// the allowed range.
161 internal override void M_CheckYE(int year, ref int era) {
163 if (year < M_MinYear || year > M_MaxYear)
164 throw new ArgumentOutOfRangeException(
166 "Only hebrew years between 5343 and 6000," +
167 " inclusive, are supported.");
171 /// A protected method checking the calendar year, month, and
174 /// <param name="year">An integer representing the calendar year.
176 /// <param name="month">An integer giving the calendar month.
178 /// <param name="era">The era number.</param>
179 /// <exception cref="T:System.ArgumentException">
180 /// The exception is thrown if the era is not equal
181 /// <see cref="F:HebrewEra"/>.
183 /// <exception cref="T:System.ArgumentOutOfRangeException">
184 /// The exception is thrown if the calendar year or month is
185 /// outside of the allowed range.
187 internal void M_CheckYME(int year, int month, ref int era) {
188 M_CheckYE(year, ref era);
189 int l = CCHebrewCalendar.last_month_of_year(year);
190 if (month < 1 || month > l) {
191 StringWriter sw = new StringWriter();
192 sw.Write("Month must be between 1 and {0}.", l);
193 throw new ArgumentOutOfRangeException("month",
199 /// A protected method checking the calendar day, month, and year
200 /// and the era number.
202 /// <param name="year">An integer representing the calendar year.
204 /// <param name="month">An integer giving the calendar month.
206 /// <param name="day">An integer giving the calendar day.
208 /// <param name="era">The era number.</param>
209 /// <exception cref="T:System.ArgumentException">
210 /// The exception is thrown if the era is not equal
211 /// <see cref="F:HebrewEra"/>.
213 /// <exception cref="T:System.ArgumentOutOfRangeException">
214 /// The exception is thrown if the calendar year, month, or day is
215 /// outside of the allowed range.
217 internal void M_CheckYMDE(int year, int month, int day,
220 M_CheckYME(year, month, ref era);
221 M_ArgumentInRange("day", day, 1, GetDaysInMonth(year, month,
227 // The following routines are commented out as they do not appear on the .NET Framework 1.1
231 /// Overridden. Adds days to a given date.
233 /// <param name="time">The
234 /// <see cref="T:System.DateTime"/> to which to add
237 /// <param name="days">The number of days to add.</param>
238 /// <returns>A new <see cref="T:System.DateTime"/> value, that
239 /// results from adding <paramref name="days"/> to the specified
240 /// DateTime.</returns>
241 /// <exception cref="T:System.ArgumentOutOfRangeException">
242 /// The exception is thrown if the
243 /// <see cref="T:System.DateTime"/> return value is not in the years
244 /// between 5343 A.M. and 6000 A.M., inclusive.
246 public override DateTime AddDays(DateTime time, int days) {
247 DateTime t = base.AddDays(time, days);
253 /// Overridden. Adds hours to a given date.
255 /// <param name="time">The
256 /// <see cref="T:System.DateTime"/> to which to add
259 /// <param name="hours">The number of hours to add.</param>
260 /// <returns>A new <see cref="T:System.DateTime"/> value, that
261 /// results from adding <paramref name="hours"/> to the specified
262 /// DateTime.</returns>
263 /// <exception cref="T:System.ArgumentOutOfRangeException">
264 /// The exception is thrown if the
265 /// <see cref="T:System.DateTime"/> return value is not in the years
266 /// between 5343 A.M. and 6000 A.M., inclusive.
268 public override DateTime AddHours(DateTime time, int hours) {
269 DateTime t = base.AddHours(time, hours);
275 /// Overridden. Adds milliseconds to a given date.
277 /// <param name="time">The
278 /// <see cref="T:System.DateTime"/> to which to add
281 /// <param name="milliseconds">The number of milliseconds given as
282 /// double to add. Keep in mind the 100 nanosecond resolution of
283 /// <see cref="T:System.DateTime"/>.
285 /// <returns>A new <see cref="T:System.DateTime"/> value, that
286 /// results from adding <paramref name="milliseconds"/> to the specified
287 /// DateTime.</returns>
288 /// <exception cref="T:System.ArgumentOutOfRangeException">
289 /// The exception is thrown if the
290 /// <see cref="T:System.DateTime"/> return value is not in the years
291 /// between 5343 A.M. and 6000 A.M., inclusive.
293 public override DateTime AddMilliseconds(DateTime time,
296 DateTime t = base.AddMilliseconds(time, milliseconds);
302 /// Overridden. Adds minutes to a given date.
304 /// <param name="time">The
305 /// <see cref="T:System.DateTime"/> to which to add
308 /// <param name="minutes">The number of minutes to add.</param>
309 /// <returns>A new <see cref="T:System.DateTime"/> value, that
310 /// results from adding <paramref name="minutes"/> to the specified
311 /// DateTime.</returns>
312 /// <exception cref="T:System.ArgumentOutOfRangeException">
313 /// The exception is thrown if the
314 /// <see cref="T:System.DateTime"/> return value is not in the years
315 /// between 5343 A.M. and 6000 A.M., inclusive.
317 public override DateTime AddMinutes(DateTime time, int minutes) {
318 DateTime t = base.AddMinutes(time, minutes);
324 /// Overridden. Adds seconds to a given date.
326 /// <param name="time">The
327 /// <see cref="T:System.DateTime"/> to which to add
330 /// <param name="seconds">The number of seconds to add.</param>
331 /// <returns>A new <see cref="T:System.DateTime"/> value, that
332 /// results from adding <paramref name="seconds"/> to the specified
333 /// DateTime.</returns>
334 /// <exception cref="T:System.ArgumentOutOfRangeException">
335 /// The exception is thrown if the
336 /// <see cref="T:System.DateTime"/> return value is not in the years
337 /// between 5343 A.M. and 6000 A.M., inclusive.
339 public override DateTime AddSeconds(DateTime time, int seconds) {
340 DateTime t = base.AddSeconds(time, seconds);
346 /// Overridden. Adds weeks to a given date.
348 /// <param name="time">The
349 /// <see cref="T:System.DateTime"/> to which to add
352 /// <param name="weeks">The number of weeks to add.</param>
353 /// <returns>A new <see cref="T:System.DateTime"/> value, that
354 /// results from adding <paramref name="weeks"/> to the specified
355 /// DateTime.</returns>
356 /// <exception cref="T:System.ArgumentOutOfRangeException">
357 /// The exception is thrown if the
358 /// <see cref="T:System.DateTime"/> return value is not in the years
359 /// between 5343 A.M. and 6000 A.M., inclusive.
361 public override DateTime AddWeeks(DateTime time, int weeks) {
362 DateTime t = base.AddWeeks(time, weeks);
368 /// Overridden. Gives the hour of the specified time.
370 /// <param name="time">The
371 /// <see cref="T:System.DateTime"/> that specifies the
374 /// <returns>An integer that gives the hour of the specified time,
375 /// starting with 0.</returns>
376 /// <exception cref="T:System.ArgumentOutOfRangeException">
377 /// The exception is thrown if the
378 /// <see cref="T:System.DateTime"/> parameter is not in the years
379 /// between 5343 A.M. and 6000 A.M., inclusive.
381 public override int GetHour(DateTime time) {
382 M_CheckDateTime(time);
383 return base.GetHour(time);
387 /// Overridden. Gives the milliseconds in the current second
388 /// of the specified time.
390 /// <param name="time">The
391 /// <see cref="T:System.DateTime"/> that specifies the
394 /// <returns>An integer that gives the milliseconds in the seconds
395 /// of the specified time, starting with 0.</returns>
396 /// <exception cref="T:System.ArgumentOutOfRangeException">
397 /// The exception is thrown if the
398 /// <see cref="T:System.DateTime"/> parameter is not in the years
399 /// between 5343 A.M. and 6000 A.M., inclusive.
401 public override double GetMilliseconds(DateTime time) {
402 M_CheckDateTime(time);
403 return base.GetMilliseconds(time);
407 /// Overridden. Gives the minute of the specified time.
409 /// <param name="time">The
410 /// <see cref="T:System.DateTime"/> that specifies the
413 /// <returns>An integer that gives the minute of the specified time,
414 /// starting with 0.</returns>
415 /// <exception cref="T:System.ArgumentOutOfRangeException">
416 /// The exception is thrown if the
417 /// <see cref="T:System.DateTime"/> parameter is not in the years
418 /// between 5343 A.M. and 6000 A.M., inclusive.
420 public override int GetMinute(DateTime time) {
421 M_CheckDateTime(time);
422 return base.GetMinute(time);
426 /// Overridden. Gives the second of the specified time.
428 /// <param name="time">The
429 /// <see cref="T:System.DateTime"/> that specifies the
432 /// <returns>An integer that gives the second of the specified time,
433 /// starting with 0.</returns>
434 /// <exception cref="T:System.ArgumentOutOfRangeException">
435 /// The exception is thrown if the
436 /// <see cref="T:System.DateTime"/> parameter is not in the years
437 /// between 5343 A.M. and 6000 A.M., inclusive.
439 public override int GetSecond(DateTime time) {
440 M_CheckDateTime(time);
441 return base.GetMinute(time);
446 /// Overrideden. Adds months to a given date.
448 /// <param name="time">The
449 /// <see cref="T:System.DateTime"/> to which to add
452 /// <param name="months">The number of months to add.</param>
453 /// <returns>A new <see cref="T:System.DateTime"/> value, that
454 /// results from adding <paramref name="months"/> to the specified
455 /// DateTime.</returns>
456 /// <exception cref="T:System.ArgumentOutOfRangeException">
457 /// The exception is thrown if the
458 /// <see cref="T:System.DateTime"/> return value is not in the years
459 /// between 5343 A.M. and 6000 A.M., inclusive.
461 public override DateTime AddMonths(DateTime time, int months) {
468 int rd = CCFixed.FromDateTime(time);
469 CCHebrewCalendar.dmy_from_fixed(
470 out d, out m, out y, rd);
480 m = GetMonthsInYear(y);
486 int my = GetMonthsInYear(y);
487 if (m+months <= my) {
497 t = ToDateTime(y, m, d, 0, 0, 0, 0);
498 t = t.Add(time.TimeOfDay);
505 /// Overridden. Adds years to a given date.
507 /// <param name="time">The
508 /// <see cref="T:System.DateTime"/> to which to add
511 /// <param name="years">The number of years to add.</param>
512 /// <returns>A new <see cref="T:System.DateTime"/> value, that
513 /// results from adding <paramref name="years"/> to the specified
514 /// DateTime.</returns>
515 /// <exception cref="T:System.ArgumentOutOfRangeException">
516 /// The exception is thrown if the
517 /// <see cref="T:System.DateTime"/> return value is not in the years
518 /// between 5343 A.M. and 6000 A.M., inclusive.
520 public override DateTime AddYears(DateTime time, int years) {
521 int rd = CCFixed.FromDateTime(time);
522 int day, month, year;
523 CCHebrewCalendar.dmy_from_fixed(
524 out day, out month, out year, rd);
526 rd = CCHebrewCalendar.fixed_from_dmy(day, month, year);
527 DateTime t = CCFixed.ToDateTime(rd);
528 t = t.Add(time.TimeOfDay);
534 /// Overriden. Gets the day of the month from
535 /// <paramref name="time"/>.
537 /// <param name="time">The
538 /// <see cref="T:System.DateTime"/> that specifies a
541 /// <returns>An integer giving the day of months, starting with 1.
543 /// <exception cref="T:System.ArgumentOutOfRangeException">
544 /// The exception is thrown if the
545 /// <see cref="T:System.DateTime"/> parameter is not in the years
546 /// between 5343 A.M. and 6000 A.M., inclusive.
548 public override int GetDayOfMonth(DateTime time) {
549 M_CheckDateTime(time);
550 int rd = CCFixed.FromDateTime(time);
551 return CCHebrewCalendar.day_from_fixed(rd);
555 /// Overriden. Gets the day of the week from the specified date.
557 /// <param name="time">The
558 /// <see cref="T:System.DateTime"/> that specifies a
561 /// <returns>An integer giving the day of months, starting with 1.
563 /// <exception cref="T:System.ArgumentOutOfRangeException">
564 /// The exception is thrown if the
565 /// <see cref="T:System.DateTime"/> parameter is not in the years
566 /// between 5343 A.M. and 6000 A.M., inclusive.
568 public override DayOfWeek GetDayOfWeek(DateTime time) {
569 M_CheckDateTime(time);
570 int rd = CCFixed.FromDateTime(time);
571 return (DayOfWeek)CCFixed.day_of_week(rd);
575 /// Overridden. Gives the number of the day in the year.
577 /// <param name="time">The
578 /// <see cref="T:System.DateTime"/> that specifies a
581 /// <returns>An integer representing the day of the year,
582 /// starting with 1.</returns>
583 /// <exception cref="T:System.ArgumentOutOfRangeException">
584 /// The exception is thrown if the
585 /// <see cref="T:System.DateTime"/> parameter is not in the years
586 /// between 5343 A.M. and 6000 A.M., inclusive.
588 public override int GetDayOfYear(DateTime time) {
589 M_CheckDateTime(time);
590 int rd = CCFixed.FromDateTime(time);
591 int year = CCHebrewCalendar.year_from_fixed(rd);
592 int rd1_7 = CCHebrewCalendar.fixed_from_dmy(1, 7, year);
593 return rd - rd1_7 + 1;
597 /// The method maps a .NET Hebrew month to a Calencdrical
598 /// Calculations Hebrew month.
600 /// <param name="month">An integer representing a month in .NET
601 /// counting (starting with Tishri).
603 /// <param name="year">An integer representing the Hebrew year.
605 /// <returns>The Hebrew month in Calendrical Calculations counting,
606 /// staring with the Hebrew month Nisan.
610 /// In .NET the month counting starts with the Hebrew month Tishri.
611 /// Calendrical Calculations starts with the month Tisan. So we must
615 internal int M_CCMonth(int month, int year) {
620 int l = CCHebrewCalendar.last_month_of_year(year);
625 return month <= 7 ? 6+month : month-7;
631 /// The method maps a Calendrical Calculations Hebrew month
632 /// to a .NET Hebrew month.
634 /// <param name="ccmonth">An integer representing a month in
635 /// Calendrical Calculations counting, starting with Nisan.
637 /// <param name="year">An integer representing the Hebrew year.
639 /// <returns>The Hebrew month in .NET counting,
640 /// staring with the Hebrew month Tishri.
644 /// In .NET the month counting starts with the Hebrew month Tishri.
645 /// Calendrical Calculations starts with the month Tisan. So we must
649 internal int M_Month(int ccmonth, int year) {
653 int l = CCHebrewCalendar.last_month_of_year(year);
654 return ccmonth + (l == 12 ? 6 : 7);
659 /// Overridden. Gives the number of days in the specified month
660 /// of the given year and era.
662 /// <param name="year">An integer that gives the year.
664 /// <param name="month">An integer that gives the month, starting
666 /// <param name="era">An integer that gives the era of the specified
668 /// <returns>An integer that gives the number of days of the
669 /// specified month.</returns>
670 /// <exception cref="T:System.ArgumentOutOfRangeException">
671 /// The exception is thrown, if <paramref name="month"/>,
672 /// <paramref name="year"/> ,or <paramref name="era"/> is outside
673 /// the allowed range.
675 public override int GetDaysInMonth(int year, int month, int era) {
676 M_CheckYME(year, month, ref era);
677 int ccmonth = M_CCMonth(month, year);
678 int rd1 = CCHebrewCalendar.fixed_from_dmy(1, ccmonth, year);
679 int rd2 = CCHebrewCalendar.fixed_from_dmy(1, ccmonth+1, year);
684 /// Overridden. Gives the number of days of the specified
685 /// year of the given era.
687 /// <param name="year">An integer that specifies the year.
689 /// <param name="era">An ineger that specifies the era.
691 /// <returns>An integer that gives the number of days of the
692 /// specified year.</returns>
693 /// <exception cref="T:System.ArgumentOutOfRangeExceiption">
694 /// The exception is thrown, if
695 /// <paramref name="year"/> or <paramref name="era"/> are outside the
698 public override int GetDaysInYear(int year, int era) {
699 M_CheckYE(year, ref era);
700 int rd1 = CCHebrewCalendar.fixed_from_dmy(1, 7, year);
701 int rd2 = CCHebrewCalendar.fixed_from_dmy(1, 7, year+1);
707 /// Overridden. Gives the era of the specified date.
709 /// <param name="time">The
710 /// <see cref="T:System.DateTime"/> that specifies a
713 /// <returns>An integer representing the era of the calendar.
715 /// <exception cref="T:System.ArgumentOutOfRangeException">
716 /// The exception is thrown if the
717 /// <see cref="T:System.DateTime"/> parameter is not in the years
718 /// between 5343 A.M. and 6000 A.M., inclusive.
720 public override int GetEra(DateTime time) {
721 M_CheckDateTime(time);
726 /// Overridden. Gives the number of the month of the specified
729 /// <param name="time">The
730 /// <see cref="T:System.DateTime"/> that specifies a
733 /// <returns>An integer representing the month,
734 /// starting with 1.</returns>
735 /// <exception cref="T:System.ArgumentOutOfRangeException">
736 /// The exception is thrown if the
737 /// <see cref="T:System.DateTime"/> parameter is not in the years
738 /// between 5343 A.M. and 6000 A.M., inclusive.
740 public override int GetMonth(DateTime time) {
741 M_CheckDateTime(time);
742 int rd = CCFixed.FromDateTime(time);
744 CCHebrewCalendar.my_from_fixed(out ccmonth, out year, rd);
745 return M_Month(ccmonth, year);
749 /// Overridden. Gives the number of months in the specified year
752 /// <param name="year">An integer that specifies the year.
754 /// <param name="era">An integer that specifies the era.
756 /// <returns>An integer that gives the number of the months in the
757 /// specified year.</returns>
758 /// <exception cref="T:System.ArgumentOutOfRangeException">
759 /// The exception is thrown, if the year or the era are not valid.
761 public override int GetMonthsInYear(int year, int era) {
762 M_CheckYE(year, ref era);
763 return CCHebrewCalendar.last_month_of_year(year);
767 /// Overridden. Gives the number of the year of the specified
770 /// <param name="time">The
771 /// <see cref="T:System.DateTime"/> that specifies a
774 /// <returns>An integer representing the year,
775 /// starting with 1.</returns>
776 /// <exception cref="T:System.ArgumentOutOfRangeException">
777 /// The exception is thrown if the
778 /// <see cref="T:System.DateTime"/> parameter is not in the years
779 /// between 5343 A.M. and 6000 A.M., inclusive.
781 public override int GetYear(DateTime time) {
782 M_CheckDateTime(time);
783 int rd = CCFixed.FromDateTime(time);
784 return CCHebrewCalendar.year_from_fixed(rd);
788 /// Overridden. Tells whether the given day
791 /// <param name="year">An integer that specifies the year in the
794 /// <param name="month">An integer that specifies the month.
796 /// <param name="day">An integer that specifies the day.
798 /// <param name="era">An integer that specifies the era.
800 /// <returns>A boolean that tells whether the given day is a leap
803 /// <exception cref="T:System.ArgumentOutOfRangeException">
804 /// The exception is thrown, if the year, month, day, or era is not
807 /// <remarks>All days in Adar II are viewed as leap days and the
808 /// last day of Adar I.
810 public override bool IsLeapDay(int year, int month, int day, int era)
812 M_CheckYMDE(year, month, day, ref era);
813 return IsLeapYear(year) &&
814 (month == 7 || (month == 6 && day == 30));
818 /// Overridden. Tells whether the given month
821 /// <param name="year">An integer that specifies the year in the
824 /// <param name="month">An integer that specifies the month.
826 /// <param name="era">An integer that specifies the era.
828 /// <returns>A boolean that tells whether the given month is a leap
831 /// <exception cref="T:System.ArgumentOutOfRangeException">
832 /// The exception is thrown, if the year, month, or era is not
836 /// Adar II is viewed as leap month.
838 public override bool IsLeapMonth(int year, int month, int era) {
839 M_CheckYME(year, month, ref era);
840 return IsLeapYear(year) && month == 7;
844 /// Overridden. Tells whether the given year
847 /// <param name="year">An integer that specifies the year in the
850 /// <param name="era">An integer that specifies the era.
852 /// <returns>A boolean that tells whether the given year is a leap
855 /// <exception cref="T:System.ArgumentOutOfRangeException">
856 /// The exception is thrown, if the year or era is not
859 public override bool IsLeapYear(int year, int era) {
860 M_CheckYE(year, ref era);
861 return CCHebrewCalendar.is_leap_year(year);
865 /// Overridden. Creates the
866 /// <see cref="T:System.DateTime"/> from the parameters.
868 /// <param name="year">An integer that gives the year in the
869 /// <paramref name="era"/>.
871 /// <param name="month">An integer that specifies the month.
873 /// <param name="day">An integer that specifies the day.
875 /// <param name="hour">An integer that specifies the hour.
877 /// <param name="minute">An integer that specifies the minute.
879 /// <param name="second">An integer that gives the second.
881 /// <param name="milliseconds">An integer that gives the
884 /// <param name="era">An integer that specifies the era.
887 /// <see cref="T:system.DateTime"/> representig the date and time.
889 /// <exception cref="T:System.ArgumentOutOfRangeException">
890 /// The exception is thrown, if at least one of the parameters
893 public override DateTime ToDateTime(int year, int month, int day,
894 int hour, int minute, int second, int milliseconds,
897 M_CheckYMDE(year, month, day, ref era);
898 M_CheckHMSM(hour, minute, second, milliseconds);
899 int ccm = M_CCMonth(month, year);
900 int rd = CCHebrewCalendar.fixed_from_dmy(day, ccm, year);
901 return CCFixed.ToDateTime(rd,
902 hour, minute, second, milliseconds);
905 public override int ToFourDigitYear (int year)
907 M_ArgumentInRange ("year", year, 0, 99);
909 int baseExtra = this.twoDigitYearMax % 100;
910 int baseCentury = this.twoDigitYearMax - baseExtra;
912 if (year <= baseExtra)
913 return baseCentury + year;
915 return baseCentury + year - 100;
918 public override CalendarAlgorithmType AlgorithmType {
920 return CalendarAlgorithmType.LunisolarCalendar;
924 static DateTime Min = new DateTime (1583, 1, 1, 0, 0, 0);
925 static DateTime Max = new DateTime (2239, 9, 29, 11, 59, 59);
927 public override DateTime MinSupportedDateTime {
933 public override DateTime MaxSupportedDateTime {
940 } // class HebrewCalendar
942 } // namespace System.Globalization