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 {
36 /// This is the Hijri calendar which might be called Islamic calendar.
39 /// <para>The calendar supports only dates in the HijriEra starting with the
43 /// The epoch of the Hijri Calendar might be adjusted by the
44 /// <see cref="F:System.Globalization.HijriCalendar.AddHijriDate"/>
45 /// property. See the discussion of the
46 /// <see cref="F:CalendricalCalculations.HijriCalendar.epoch">
49 /// of the Hijri calendar.
51 /// <para>The implementation uses the
52 /// <see cref="N:CalendricalCalculations"/> namespace.
56 [MonoTODO ("Fix serialization compatibility with MS.NET")]
57 public class HijriCalendar : Calendar {
61 public HijriCalendar() {
62 M_AbbrEraNames = new string[] {"A.H."};
63 M_EraNames = new string[] {"Anno Hegirae"};
64 if (M_TwoDigitYearMax == 99)
65 M_TwoDigitYearMax = 1451;
69 /// The era number for the Anno Hegirae (A.H.) era.
71 public static readonly int HijriEra = 1;
74 /// The minimum fixed day number supported by the Hijri calendar.
76 internal static readonly int M_MinFixed =
77 CCHijriCalendar.fixed_from_dmy(1, 1, 1);
79 /// The maximum fixed day number supported by the Hijri calendar.
81 internal static readonly int M_MaxFixed =
82 CCGregorianCalendar.fixed_from_dmy(31, 12, 9999);
84 /// <value>Overridden. Gives the eras supported by the Gregorian
85 /// calendar as an array of integers.
87 public override int[] Eras {
89 return new int[] { HijriEra };
95 public int HijriAdjustment {
97 throw new NotImplementedException ();
100 throw new NotImplementedException ();
105 int twoDigitYearMax = 1451;
107 [MonoTODO ("Add call into operating system")]
108 public override int TwoDigitYearMax
111 return twoDigitYearMax;
114 M_ArgumentInRange ("value", value, 100, M_MaxYear);
116 twoDigitYearMax = value;
121 /// Protected field storing the
122 /// <see cref="F:AddHijriDate"/>.
124 internal int M_AddHijriDate = 0;
126 // TODO: I don't know currently, which sign to use with the parameter.
127 /// <value>An integer property representing the adjustment to the epoch
128 /// of the Hijri calendar. Not supported by .NET.
130 internal virtual int AddHijriDate {
132 return M_AddHijriDate;
135 if (value < -3 && value > 3)
136 throw new ArgumentOutOfRangeException(
138 "Value should be between -3 and 3.");
139 M_AddHijriDate = value;
144 /// A protected method checking an
145 /// <see cref="F:AddHijriDate"/> adjusted fixed day number.
147 /// <param name="param">A string giving the name of the parameter
148 /// to check.</param>
149 /// <param name="rdHijri">An integer giving the AddHijriDate adjusted
150 /// fixed day number.
152 /// <exception cref="T:System.ArgumentOutOfRangeException">
153 /// Exception is thrown, if the AddHijriDate adjusted fixed day
154 /// number is outside the supported range.
156 internal void M_CheckFixedHijri(string param, int rdHijri) {
157 if (rdHijri < M_MinFixed || rdHijri > M_MaxFixed-AddHijriDate) {
158 StringWriter sw = new StringWriter();
159 int day, month, year;
160 CCHijriCalendar.dmy_from_fixed(out day, out month,
161 out year, M_MaxFixed-AddHijriDate);
162 if (AddHijriDate != 0) {
163 sw.Write("This HijriCalendar " +
164 "(AddHijriDate {0})" +
165 " allows dates from 1. 1. 1 to " +
170 sw.Write("HijriCalendar allows dates from " +
171 "1.1.1 to {0}.{1}.{2}.",
174 throw new ArgumentOutOfRangeException(param,
180 /// A protected member checking a
181 /// <see cref="T:System.DateTime"/> value.
183 /// <param name="time">The
184 /// <see cref="T:System.DateTime"/>
187 /// <exception cref="T:System.ArgumentOutOfRangeException">
188 /// The exception is thrown if the
189 /// <see cref="T:System.DateTime"/> parameter is not in the supported
190 /// range of the Hijri calendar.
192 internal void M_CheckDateTime(DateTime time) {
193 int rd = CCFixed.FromDateTime(time) - AddHijriDate;
194 M_CheckFixedHijri("time", rd);
198 /// Protected member which computes the
199 /// <see cref="F:AddHijriDate"/>
200 /// adjusted fixed day number from a
201 /// <see cref="T:System.DateTime"/>.
203 /// <param name="time">The
204 /// <see cref="T:System.DateTime"/>
208 /// <see cref="F:AddHijriDate"/> adjusted fixed day number.
210 internal int M_FromDateTime(DateTime time) {
211 return CCFixed.FromDateTime(time) - AddHijriDate;
215 /// Protected member which converts the
216 /// <see cref="F:AddHijriDate"/>
217 /// adjusted fixed day number the a
218 /// <see cref="T:System.DateTime"/> value.
220 /// <param name="rd">The
221 /// <see cref="F:AddHijriDate"/> adjusted fixed day number.
223 /// <returns>The converted
224 /// <see cref="T:System.DateTime"/> value.
226 internal DateTime M_ToDateTime(int rd) {
227 return CCFixed.ToDateTime(rd+AddHijriDate);
231 /// Protected member which converts the
232 /// <see cref="F:AddHijriDate"/>
233 /// adjusted fixed day number the a
234 /// <see cref="T:System.DateTime"/> value using a number
235 /// of time parameters.
237 /// <param name="date">The
238 /// <see cref="F:AddHijriDate"/> adjusted fixed day number.
240 /// <param name="hour">An integer that specifies the hour.
242 /// <param name="minute">An integer that specifies the minute.
244 /// <param name="second">An integer that gives the second.
246 /// <param name="milliseconds">An integer that gives the
249 /// <returns>The converted
250 /// <see cref="T:System.DateTime"/> value.
252 internal DateTime M_ToDateTime(int date,
253 int hour, int minute, int second, int milliseconds)
255 return CCFixed.ToDateTime(date+AddHijriDate,
256 hour, minute, second, milliseconds);
260 /// A protected method checking the era number.
262 /// <param name="era">The era number.</param>
263 /// <exception name="T:System.ArgumentException">
264 /// The exception is thrown if the era is not equal
265 /// <see cref="F:HijriEra"/>.
267 internal void M_CheckEra(ref int era) {
268 if (era == CurrentEra)
271 throw new ArgumentException("Era value was not valid.");
275 /// A protected method checking calendar year and the era number.
277 /// <param name="year">An integer representing the calendar year.
279 /// <param name="era">The era number.</param>
280 /// <exception cref="T:System.ArgumentException">
281 /// The exception is thrown if the era is not equal
282 /// <see cref="F:HijriEra"/>.
284 /// <exception cref="T:System.ArgumentOutOfRangeException">
285 /// The exception is thrown if the calendar year is outside of
286 /// the allowed range.
288 internal override void M_CheckYE(int year, ref int era) {
290 M_ArgumentInRange("year", year, 1, 9666);
294 /// A protected method checking the calendar year, month, and
297 /// <param name="year">An integer representing the calendar year.
299 /// <param name="month">An integer giving the calendar month.
301 /// <param name="era">The era number.</param>
302 /// <exception cref="T:System.ArgumentException">
303 /// The exception is thrown if the era is not equal
304 /// <see cref="F:HijriEra"/>.
306 /// <exception cref="T:System.ArgumentOutOfRangeException">
307 /// The exception is thrown if the calendar year or month is
308 /// outside of the allowed range.
310 internal void M_CheckYME(int year, int month, ref int era) {
311 M_CheckYE(year, ref era);
312 if (month < 1 || month > 12)
313 throw new ArgumentOutOfRangeException("month",
314 "Month must be between one and twelve.");
316 int rd = CCHijriCalendar.fixed_from_dmy(1, month, year);
317 M_CheckFixedHijri("month", rd);
322 /// A protected method checking the calendar day, month, and year
323 /// and the era number.
325 /// <param name="year">An integer representing the calendar year.
327 /// <param name="month">An integer giving the calendar month.
329 /// <param name="day">An integer giving the calendar day.
331 /// <param name="era">The era number.</param>
332 /// <exception cref="T:System.ArgumentException">
333 /// The exception is thrown if the era is not equal
334 /// <see cref="F:HijriEra"/>.
336 /// <exception cref="T:System.ArgumentOutOfRangeException">
337 /// The exception is thrown if the calendar year, month, or day is
338 /// outside of the allowed range.
340 internal void M_CheckYMDE(int year, int month, int day, ref int era)
342 M_CheckYME(year, month, ref era);
343 M_ArgumentInRange("day", day, 1,
344 GetDaysInMonth(year, month, HijriEra));
346 int rd = CCHijriCalendar.fixed_from_dmy(day, month,
348 M_CheckFixedHijri("day", rd);
354 // The following routines are commented out as they do not appear on the .NET Framework 1.1
358 /// Overridden. Adds days to a given date.
360 /// <param name="time">The
361 /// <see cref="T:System.DateTime"/> to which to add
364 /// <param name="days">The number of days to add.</param>
365 /// <returns>A new <see cref="T:System.DateTime"/> value, that
366 /// results from adding <paramref name="days"/> to the specified
367 /// DateTime.</returns>
368 /// <exception cref="T:System.ArgumentOutOfRangeException">
369 /// The exception is thrown if the
370 /// <see cref="T:System.DateTime"/> return value is not in the
371 /// supported range of the Hijri calendar.
373 public override DateTime AddDays(DateTime time, int days) {
374 DateTime t = base.AddDays(time, days);
380 /// Overridden. Adds hours to a given date.
382 /// <param name="time">The
383 /// <see cref="T:System.DateTime"/> to which to add
386 /// <param name="hours">The number of hours to add.</param>
387 /// <returns>A new <see cref="T:System.DateTime"/> value, that
388 /// results from adding <paramref name="hours"/> to the specified
389 /// DateTime.</returns>
390 /// <exception cref="T:System.ArgumentOutOfRangeException">
391 /// The exception is thrown if the
392 /// <see cref="T:System.DateTime"/> return value is not in the
393 /// supported range of the Hijri calendar.
395 public override DateTime AddHours(DateTime time, int hours) {
396 DateTime t = base.AddHours(time, hours);
402 /// Overridden. Adds milliseconds to a given date.
404 /// <param name="time">The
405 /// <see cref="T:System.DateTime"/> to which to add
408 /// <param name="milliseconds">The number of milliseconds given as
409 /// double to add. Keep in mind the 100 nanosecond resolution of
410 /// <see cref="T:System.DateTime"/>.
412 /// <returns>A new <see cref="T:System.DateTime"/> value, that
413 /// results from adding <paramref name="milliseconds"/> to the specified
414 /// DateTime.</returns>
415 /// <exception cref="T:System.ArgumentOutOfRangeException">
416 /// The exception is thrown if the
417 /// <see cref="T:System.DateTime"/> return value is not in the
418 /// supported range of the Hijri calendar.
420 public override DateTime AddMilliseconds(DateTime time,
423 DateTime t = base.AddMilliseconds(time, milliseconds);
429 /// Overridden. Adds minutes to a given date.
431 /// <param name="time">The
432 /// <see cref="T:System.DateTime"/> to which to add
435 /// <param name="minutes">The number of minutes to add.</param>
436 /// <returns>A new <see cref="T:System.DateTime"/> value, that
437 /// results from adding <paramref name="minutes"/> to the specified
438 /// DateTime.</returns>
439 /// <exception cref="T:System.ArgumentOutOfRangeException">
440 /// The exception is thrown if the
441 /// <see cref="T:System.DateTime"/> return value is not in the
442 /// supported range of the Hijri calendar.
444 public override DateTime AddMinutes(DateTime time, int minutes) {
445 DateTime t = base.AddMinutes(time, minutes);
451 /// Overridden. Adds seconds to a given date.
453 /// <param name="time">The
454 /// <see cref="T:System.DateTime"/> to which to add
457 /// <param name="seconds">The number of seconds to add.</param>
458 /// <returns>A new <see cref="T:System.DateTime"/> value, that
459 /// results from adding <paramref name="seconds"/> to the specified
460 /// DateTime.</returns>
461 /// <exception cref="T:System.ArgumentOutOfRangeException">
462 /// The exception is thrown if the
463 /// <see cref="T:System.DateTime"/> return value is not in the
464 /// supported range of the Hijri calendar.
466 public override DateTime AddSeconds(DateTime time, int seconds) {
467 DateTime t = base.AddSeconds(time, seconds);
473 /// Overridden. Adds weeks to a given date.
475 /// <param name="time">The
476 /// <see cref="T:System.DateTime"/> to which to add
479 /// <param name="weeks">The number of weeks to add.</param>
480 /// <returns>A new <see cref="T:System.DateTime"/> value, that
481 /// results from adding <paramref name="weeks"/> to the specified
482 /// DateTime.</returns>
483 /// <exception cref="T:System.ArgumentOutOfRangeException">
484 /// The exception is thrown if the
485 /// <see cref="T:System.DateTime"/> return value is not in the
486 /// supported range of the Hijri calendar.
488 public override DateTime AddWeeks(DateTime time, int weeks) {
489 DateTime t = base.AddWeeks(time, weeks);
495 /// Overridden. Gives the hour of the specified time.
497 /// <param name="time">The
498 /// <see cref="T:System.DateTime"/> that specifies the
501 /// <returns>An integer that gives the hour of the specified time,
502 /// starting with 0.</returns>
503 /// <exception cref="T:System.ArgumentOutOfRangeException">
504 /// The exception is thrown if the
505 /// <see cref="T:System.DateTime"/> parameter is not in the
506 /// supported range of the Hijri calendar.
508 public override int GetHour(DateTime time) {
509 M_CheckDateTime(time);
510 return base.GetHour(time);
514 /// Overridden. Gives the milliseconds in the current second
515 /// of the specified time.
517 /// <param name="time">The
518 /// <see cref="T:System.DateTime"/> that specifies the
521 /// <returns>An integer that gives the milliseconds in the seconds
522 /// of the specified time, starting with 0.</returns>
523 /// <exception cref="T:System.ArgumentOutOfRangeException">
524 /// The exception is thrown if the
525 /// <see cref="T:System.DateTime"/> parameter is not in the
526 /// supported range of the Hijri calendar.
528 public override double GetMilliseconds(DateTime time) {
529 M_CheckDateTime(time);
530 return base.GetMilliseconds(time);
534 /// Overridden. Gives the minute of the specified time.
536 /// <param name="time">The
537 /// <see cref="T:System.DateTime"/> that specifies the
540 /// <returns>An integer that gives the minute of the specified time,
541 /// starting with 0.</returns>
542 /// <exception cref="T:System.ArgumentOutOfRangeException">
543 /// The exception is thrown if the
544 /// <see cref="T:System.DateTime"/> parameter is not in the
545 /// supported range of the Hijri calendar.
547 public override int GetMinute(DateTime time) {
548 M_CheckDateTime(time);
549 return base.GetMinute(time);
553 /// Overridden. Gives the second of the specified time.
555 /// <param name="time">The
556 /// <see cref="T:System.DateTime"/> that specifies the
559 /// <returns>An integer that gives the second of the specified time,
560 /// starting with 0.</returns>
561 /// <exception cref="T:System.ArgumentOutOfRangeException">
562 /// The exception is thrown if the
563 /// <see cref="T:System.DateTime"/> parameter is not in the
564 /// supported range of the Hijri calendar.
566 public override int GetSecond(DateTime time) {
567 M_CheckDateTime(time);
568 return base.GetMinute(time);
573 /// Overrideden. Adds months to a given date.
575 /// <param name="time">The
576 /// <see cref="T:System.DateTime"/> to which to add
579 /// <param name="months">The number of months to add.</param>
580 /// <returns>A new <see cref="T:System.DateTime"/> value, that
581 /// results from adding <paramref name="months"/> to the specified
582 /// DateTime.</returns>
583 /// <exception cref="T:System.ArgumentOutOfRangeException">
584 /// The exception is thrown if the
585 /// <see cref="T:System.DateTime"/> return value is not in the
586 /// supported range of the Hijri calendar.
588 public override DateTime AddMonths(DateTime time, int months) {
589 int rd = M_FromDateTime(time);
590 int day, month, year;
591 CCHijriCalendar.dmy_from_fixed(
592 out day, out month, out year, rd);
594 year += CCMath.div_mod(out month, month, 12);
595 rd = CCHijriCalendar.fixed_from_dmy(day, month, year);
596 M_CheckFixedHijri("time", rd);
597 DateTime t = M_ToDateTime(rd);
598 return t.Add(time.TimeOfDay);
602 /// Overrideden. Adds years to a given date.
604 /// <param name="time">The
605 /// <see cref="T:System.DateTime"/> to which to add
608 /// <param name="years">The number of years to add.</param>
609 /// <returns>A new <see cref="T:System.DateTime"/> value, that
610 /// results from adding <paramref name="years"/> to the specified
611 /// DateTime.</returns>
612 /// <exception cref="T:System.ArgumentOutOfRangeException">
613 /// The exception is thrown if the
614 /// <see cref="T:System.DateTime"/> return value is not in the
615 /// supported range of the Hijri calendar.
617 public override DateTime AddYears(DateTime time, int years) {
618 int rd = M_FromDateTime(time);
619 int day, month, year;
620 CCHijriCalendar.dmy_from_fixed(
621 out day, out month, out year, rd);
623 rd = CCHijriCalendar.fixed_from_dmy(day, month, year);
624 M_CheckFixedHijri("time", rd);
625 DateTime t = M_ToDateTime(rd);
626 return t.Add(time.TimeOfDay);
630 /// Overriden. Gets the day of the month from
631 /// <paramref name="time"/>.
633 /// <param name="time">The
634 /// <see cref="T:System.DateTime"/> that specifies a
637 /// <returns>An integer giving the day of months, starting with 1.
639 /// <exception cref="T:System.ArgumentOutOfRangeException">
640 /// The exception is thrown if the
641 /// <see cref="T:System.DateTime"/> parameter is not in the
642 /// supported range of the Hijri calendar.
644 public override int GetDayOfMonth(DateTime time) {
645 int rd = M_FromDateTime(time);
646 M_CheckFixedHijri("time", rd);
647 return CCHijriCalendar.day_from_fixed(rd);
651 /// Overriden. Gets the day of the week from the specified date.
653 /// <param name="time">The
654 /// <see cref="T:System.DateTime"/> that specifies a
657 /// <returns>An integer giving the day of months, starting with 1.
659 /// <exception cref="T:System.ArgumentOutOfRangeException">
660 /// The exception is thrown if the
661 /// <see cref="T:System.DateTime"/> parameter is not in the
662 /// supported range of the Hijri calendar.
664 public override DayOfWeek GetDayOfWeek(DateTime time) {
665 int rd = M_FromDateTime(time);
666 M_CheckFixedHijri("time", rd);
667 return (DayOfWeek)CCFixed.day_of_week(rd);
671 /// Overridden. Gives the number of the day in the year.
673 /// <param name="time">The
674 /// <see cref="T:System.DateTime"/> that specifies a
677 /// <returns>An integer representing the day of the year,
678 /// starting with 1.</returns>
679 /// <exception cref="T:System.ArgumentOutOfRangeException">
680 /// The exception is thrown if the
681 /// <see cref="T:System.DateTime"/> parameter is not in the
682 /// supported range of the Hijri calendar.
684 public override int GetDayOfYear(DateTime time) {
685 int rd = M_FromDateTime(time);
686 M_CheckFixedHijri("time", rd);
687 int year = CCHijriCalendar.year_from_fixed(rd);
688 int rd1_1 = CCHijriCalendar.fixed_from_dmy(1, 1, year);
689 return rd - rd1_1 + 1;
693 /// Overridden. Gives the number of days in the specified month
694 /// of the given year and era.
696 /// <param name="year">An integer that gives the year.
698 /// <param name="month">An integer that gives the month, starting
700 /// <param name="era">An intger that gives the era of the specified
702 /// <returns>An integer that gives the number of days of the
703 /// specified month.</returns>
704 /// <exception cref="T:System.ArgumentOutOfRangeException">
705 /// The exception is thrown, if <paramref name="month"/>,
706 /// <paramref name="year"/> ,or <paramref name="era"/> is outside
707 /// the allowed range.
709 public override int GetDaysInMonth(int year, int month, int era) {
710 M_CheckYME(year, month, ref era);
711 int rd1 = CCHijriCalendar.fixed_from_dmy(1, month, year);
712 int rd2 = CCHijriCalendar.fixed_from_dmy(1, month+1, year);
717 /// Overridden. Gives the number of days of the specified
718 /// year of the given era.
720 /// <param name="year">An integer that specifies the year.
722 /// <param name="era">An ineger that specifies the era.
724 /// <returns>An integer that gives the number of days of the
725 /// specified year.</returns>
726 /// <exception cref="T:System.ArgumentOutOfRangeExceiption">
727 /// The exception is thrown, if
728 /// <paramref name="year"/> is outside the allowed range.
730 public override int GetDaysInYear(int year, int era) {
731 M_CheckYE(year, ref era);
732 int rd1 = CCHijriCalendar.fixed_from_dmy(1, 1, year);
733 int rd2 = CCHijriCalendar.fixed_from_dmy(1, 1, year+1);
739 /// Overridden. Gives the era of the specified date.
741 /// <param name="time">The
742 /// <see cref="T:System.DateTime"/> that specifies a
745 /// <returns>An integer representing the era of the calendar.
747 /// <exception cref="T:System.ArgumentOutOfRangeException">
748 /// The exception is thrown if the
749 /// <see cref="T:System.DateTime"/> parameter is not in the
750 /// supported range of the Hijri calendar.
752 public override int GetEra(DateTime time) {
753 M_CheckDateTime(time);
758 /// Overridden. Gives the number of the month of the specified
761 /// <param name="time">The
762 /// <see cref="T:System.DateTime"/> that specifies a
765 /// <returns>An integer representing the month,
766 /// starting with 1.</returns>
767 /// <exception cref="T:System.ArgumentOutOfRangeException">
768 /// The exception is thrown if the
769 /// <see cref="T:System.DateTime"/> parameter is not in the
770 /// supported range of the Hijri calendar.
772 public override int GetMonth(DateTime time) {
773 int rd = M_FromDateTime(time);
774 M_CheckFixedHijri("time", rd);
775 return CCHijriCalendar.month_from_fixed(rd);
779 /// Overridden. Gives the number of months in the specified year
782 /// <param name="year">An integer that specifies the year.
784 /// <param name="era">An integer that specifies the era.
786 /// <returns>An integer that gives the number of the months in the
787 /// specified year.</returns>
788 /// <exception cref="T:System.ArgumentOutOfRangeException">
789 /// The exception is thrown, if the year or the era are not valid.
791 public override int GetMonthsInYear(int year, int era) {
792 M_CheckYE(year, ref era);
797 /// Overridden. Gives the number of the year of the specified
800 /// <param name="time">The
801 /// <see cref="T:System.DateTime"/> that specifies a
804 /// <returns>An integer representing the year,
805 /// starting with 1.</returns>
806 /// <exception cref="T:System.ArgumentOutOfRangeException">
807 /// The exception is thrown if the
808 /// <see cref="T:System.DateTime"/> parameter is not in the
809 /// supported range of the Hijri calendar.
811 public override int GetYear(DateTime time) {
812 int rd = M_FromDateTime(time);
813 M_CheckFixedHijri("time", rd);
814 return CCHijriCalendar.year_from_fixed(rd);
818 /// Overridden. Tells whether the given day
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="day">An integer that specifies the day.
828 /// <param name="era">An integer that specifies the era.
830 /// <returns>A boolean that tells whether the given day is a leap
833 /// <exception cref="T:System.ArgumentOutOfRangeException">
834 /// The exception is thrown, if the year, month, day, or era is not
837 public override bool IsLeapDay(int year, int month, int day, int era)
839 M_CheckYMDE(year, month, day, ref era);
840 return IsLeapYear(year) && month == 12 && day == 30;
844 /// Overridden. Tells whether the given month
847 /// <param name="year">An integer that specifies the year in the
850 /// <param name="month">An integer that specifies the month.
852 /// <param name="era">An integer that specifies the era.
854 /// <returns>A boolean that tells whether the given month is a leap
857 /// <exception cref="T:System.ArgumentOutOfRangeException">
858 /// The exception is thrown, if the year, month, or era is not
861 public override bool IsLeapMonth(int year, int month, int era) {
862 M_CheckYME(year, month, ref era);
867 /// Overridden. Tells whether the given year
870 /// <param name="year">An integer that specifies the year in the
873 /// <param name="era">An integer that specifies the era.
875 /// <returns>A boolean that tells whether the given year is a leap
878 /// <exception cref="T:System.ArgumentOutOfRangeException">
879 /// The exception is thrown, if the year or era is not
882 public override bool IsLeapYear(int year, int era) {
883 M_CheckYE(year, ref era);
884 return CCHijriCalendar.is_leap_year(year);
888 /// Overridden. Creates the
889 /// <see cref="T:System.DateTime"/> from the parameters.
891 /// <param name="year">An integer that gives the year in the
892 /// <paramref name="era"/>.
894 /// <param name="month">An integer that specifies the month.
896 /// <param name="day">An integer that specifies the day.
898 /// <param name="hour">An integer that specifies the hour.
900 /// <param name="minute">An integer that specifies the minute.
902 /// <param name="second">An integer that gives the second.
904 /// <param name="milliseconds">An integer that gives the
907 /// <param name="era">An integer that specifies the era.
910 /// <see cref="T:system.DateTime"/> representig the date and time.
912 /// <exception cref="T:System.ArgumentOutOfRangeException">
913 /// The exception is thrown, if at least one of the parameters
916 public override DateTime ToDateTime(int year, int month, int day,
917 int hour, int minute, int second, int milliseconds,
920 M_CheckYMDE(year, month, day, ref era);
921 M_CheckHMSM(hour, minute, second, milliseconds);
922 int rd = CCHijriCalendar.fixed_from_dmy(day, month, year);
923 return M_ToDateTime(rd,
924 hour, minute, second, milliseconds);
928 public override int ToFourDigitYear(int year)
930 throw new NotImplementedException();
934 public override CalendarAlgorithmType AlgorithmType {
936 return CalendarAlgorithmType.LunarCalendar;
940 static DateTime Min = new DateTime (622, 7, 18, 0, 0, 0);
941 static DateTime Max = new DateTime (9999, 12, 31, 11, 59, 59);
943 public override DateTime MinSupportedDateTime {
949 public override DateTime MaxSupportedDateTime {
956 } // class HijriCalendar
958 } // namespace System.Globalization