1 // System.Globalization.UmAlQuraCalendar.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // (C) Ulrich Kunitz 2002
8 // Copyright (C) 2007 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // This code is almost a copy of HijriCalendar, except that
32 // - it does not support HijriAdjustment.
33 // - HijriEra->UmAlQuraEra.
36 namespace System.Globalization {
43 /// This is the Hijri calendar which might be called Islamic calendar.
46 /// <para>The calendar supports only dates in the UmAlQuraEra starting with the
50 /// The epoch of the Hijri Calendar might be adjusted by the
51 /// <see cref="F:System.Globalization.HijriCalendar.AddHijriDate"/>
52 /// property. See the discussion of the
53 /// <see cref="F:CalendricalCalculations.HijriCalendar.epoch">
56 /// of the Hijri calendar.
58 /// <para>The implementation uses the
59 /// <see cref="N:CalendricalCalculations"/> namespace.
63 [MonoTODO ("Serialization format not compatible with .NET")]
64 public class UmAlQuraCalendar : Calendar {
68 public UmAlQuraCalendar() {
69 M_AbbrEraNames = new string[] {"A.H."};
70 M_EraNames = new string[] {"Anno Hegirae"};
71 if (twoDigitYearMax == 99)
72 twoDigitYearMax = 1451;
76 /// The era number for the Anno Hegirae (A.H.) era.
78 public const int UmAlQuraEra = 1;
81 /// The minimum fixed day number supported by the Hijri calendar.
83 internal static readonly int M_MinFixed =
84 CCHijriCalendar.fixed_from_dmy(1, 1, 1);
86 /// The maximum fixed day number supported by the Hijri calendar.
88 internal static readonly int M_MaxFixed =
89 CCGregorianCalendar.fixed_from_dmy(31, 12, 9999);
91 /// <value>Overridden. Gives the eras supported by the Gregorian
92 /// calendar as an array of integers.
94 public override int[] Eras {
96 return new int[] { UmAlQuraEra };
100 // FIXME: [MonoTODO ("Add call into operating system")]
101 public override int TwoDigitYearMax
104 return twoDigitYearMax;
108 M_ArgumentInRange ("value", value, 100, M_MaxYear);
110 twoDigitYearMax = value;
115 /// Protected field storing the
116 /// <see cref="F:AddHijriDate"/>.
118 internal int M_AddHijriDate = 0;
120 // TODO: I don't know currently, which sign to use with the parameter.
121 /// <value>An integer property representing the adjustment to the epoch
122 /// of the Hijri calendar. Not supported by .NET.
124 internal virtual int AddHijriDate {
126 return M_AddHijriDate;
130 if (value < -3 && value > 3)
131 throw new ArgumentOutOfRangeException(
133 "Value should be between -3 and 3.");
134 M_AddHijriDate = value;
139 /// A protected method checking an
140 /// <see cref="F:AddHijriDate"/> adjusted fixed day number.
142 /// <param name="param">A string giving the name of the parameter
143 /// to check.</param>
144 /// <param name="rdHijri">An integer giving the AddHijriDate adjusted
145 /// fixed day number.
147 /// <exception cref="T:System.ArgumentOutOfRangeException">
148 /// Exception is thrown, if the AddHijriDate adjusted fixed day
149 /// number is outside the supported range.
151 internal void M_CheckFixedHijri(string param, int rdHijri) {
152 if (rdHijri < M_MinFixed || rdHijri > M_MaxFixed-AddHijriDate) {
153 StringWriter sw = new StringWriter();
154 int day, month, year;
155 CCHijriCalendar.dmy_from_fixed(out day, out month,
156 out year, M_MaxFixed-AddHijriDate);
157 if (AddHijriDate != 0) {
158 sw.Write("This HijriCalendar " +
159 "(AddHijriDate {0})" +
160 " allows dates from 1. 1. 1 to " +
165 sw.Write("HijriCalendar allows dates from " +
166 "1.1.1 to {0}.{1}.{2}.",
169 throw new ArgumentOutOfRangeException(param,
175 /// A protected member checking a
176 /// <see cref="T:System.DateTime"/> value.
178 /// <param name="time">The
179 /// <see cref="T:System.DateTime"/>
182 /// <exception cref="T:System.ArgumentOutOfRangeException">
183 /// The exception is thrown if the
184 /// <see cref="T:System.DateTime"/> parameter is not in the supported
185 /// range of the Hijri calendar.
187 internal void M_CheckDateTime(DateTime time) {
188 int rd = CCFixed.FromDateTime(time) - AddHijriDate;
189 M_CheckFixedHijri("time", rd);
193 /// Protected member which computes the
194 /// <see cref="F:AddHijriDate"/>
195 /// adjusted fixed day number from a
196 /// <see cref="T:System.DateTime"/>.
198 /// <param name="time">The
199 /// <see cref="T:System.DateTime"/>
203 /// <see cref="F:AddHijriDate"/> adjusted fixed day number.
205 internal int M_FromDateTime(DateTime time) {
206 return CCFixed.FromDateTime(time) - AddHijriDate;
210 /// Protected member which converts the
211 /// <see cref="F:AddHijriDate"/>
212 /// adjusted fixed day number the a
213 /// <see cref="T:System.DateTime"/> value.
215 /// <param name="rd">The
216 /// <see cref="F:AddHijriDate"/> adjusted fixed day number.
218 /// <returns>The converted
219 /// <see cref="T:System.DateTime"/> value.
221 internal DateTime M_ToDateTime(int rd) {
222 return CCFixed.ToDateTime(rd+AddHijriDate);
226 /// Protected member which converts the
227 /// <see cref="F:AddHijriDate"/>
228 /// adjusted fixed day number the a
229 /// <see cref="T:System.DateTime"/> value using a number
230 /// of time parameters.
232 /// <param name="date">The
233 /// <see cref="F:AddHijriDate"/> adjusted fixed day number.
235 /// <param name="hour">An integer that specifies the hour.
237 /// <param name="minute">An integer that specifies the minute.
239 /// <param name="second">An integer that gives the second.
241 /// <param name="milliseconds">An integer that gives the
244 /// <returns>The converted
245 /// <see cref="T:System.DateTime"/> value.
247 internal DateTime M_ToDateTime(int date,
248 int hour, int minute, int second, int milliseconds)
250 return CCFixed.ToDateTime(date+AddHijriDate,
251 hour, minute, second, milliseconds);
255 /// A protected method checking the era number.
257 /// <param name="era">The era number.</param>
258 /// <exception name="T:System.ArgumentException">
259 /// The exception is thrown if the era is not equal
260 /// <see cref="F:UmAlQuraEra"/>.
262 internal void M_CheckEra(ref int era) {
263 if (era == CurrentEra)
265 if (era != UmAlQuraEra)
266 throw new ArgumentException("Era value was not valid.");
270 /// A protected method checking calendar year and the era number.
272 /// <param name="year">An integer representing the calendar year.
274 /// <param name="era">The era number.</param>
275 /// <exception cref="T:System.ArgumentException">
276 /// The exception is thrown if the era is not equal
277 /// <see cref="F:UmAlQuraEra"/>.
279 /// <exception cref="T:System.ArgumentOutOfRangeException">
280 /// The exception is thrown if the calendar year is outside of
281 /// the allowed range.
283 internal override void M_CheckYE(int year, ref int era) {
285 M_ArgumentInRange("year", year, 1, 9666);
289 /// A protected method checking the calendar year, month, and
292 /// <param name="year">An integer representing the calendar year.
294 /// <param name="month">An integer giving the calendar month.
296 /// <param name="era">The era number.</param>
297 /// <exception cref="T:System.ArgumentException">
298 /// The exception is thrown if the era is not equal
299 /// <see cref="F:UmAlQuraEra"/>.
301 /// <exception cref="T:System.ArgumentOutOfRangeException">
302 /// The exception is thrown if the calendar year or month is
303 /// outside of the allowed range.
305 internal void M_CheckYME(int year, int month, ref int era) {
306 M_CheckYE(year, ref era);
307 if (month < 1 || month > 12)
308 throw new ArgumentOutOfRangeException("month",
309 "Month must be between one and twelve.");
311 int rd = CCHijriCalendar.fixed_from_dmy(1, month, year);
312 M_CheckFixedHijri("month", rd);
317 /// A protected method checking the calendar day, month, and year
318 /// and the era number.
320 /// <param name="year">An integer representing the calendar year.
322 /// <param name="month">An integer giving the calendar month.
324 /// <param name="day">An integer giving the calendar day.
326 /// <param name="era">The era number.</param>
327 /// <exception cref="T:System.ArgumentException">
328 /// The exception is thrown if the era is not equal
329 /// <see cref="F:UmAlQuraEra"/>.
331 /// <exception cref="T:System.ArgumentOutOfRangeException">
332 /// The exception is thrown if the calendar year, month, or day is
333 /// outside of the allowed range.
335 internal void M_CheckYMDE(int year, int month, int day, ref int era)
337 M_CheckYME(year, month, ref era);
338 M_ArgumentInRange("day", day, 1,
339 GetDaysInMonth(year, month, UmAlQuraEra));
341 int rd = CCHijriCalendar.fixed_from_dmy(day, month,
343 M_CheckFixedHijri("day", rd);
349 // The following routines are commented out as they do not appear on the .NET Framework 1.1
353 /// Overridden. Adds days to a given date.
355 /// <param name="time">The
356 /// <see cref="T:System.DateTime"/> to which to add
359 /// <param name="days">The number of days to add.</param>
360 /// <returns>A new <see cref="T:System.DateTime"/> value, that
361 /// results from adding <paramref name="days"/> to the specified
362 /// DateTime.</returns>
363 /// <exception cref="T:System.ArgumentOutOfRangeException">
364 /// The exception is thrown if the
365 /// <see cref="T:System.DateTime"/> return value is not in the
366 /// supported range of the Hijri calendar.
368 public override DateTime AddDays(DateTime time, int days) {
369 DateTime t = base.AddDays(time, days);
375 /// Overridden. Adds hours to a given date.
377 /// <param name="time">The
378 /// <see cref="T:System.DateTime"/> to which to add
381 /// <param name="hours">The number of hours to add.</param>
382 /// <returns>A new <see cref="T:System.DateTime"/> value, that
383 /// results from adding <paramref name="hours"/> to the specified
384 /// DateTime.</returns>
385 /// <exception cref="T:System.ArgumentOutOfRangeException">
386 /// The exception is thrown if the
387 /// <see cref="T:System.DateTime"/> return value is not in the
388 /// supported range of the Hijri calendar.
390 public override DateTime AddHours(DateTime time, int hours) {
391 DateTime t = base.AddHours(time, hours);
397 /// Overridden. Adds milliseconds to a given date.
399 /// <param name="time">The
400 /// <see cref="T:System.DateTime"/> to which to add
403 /// <param name="milliseconds">The number of milliseconds given as
404 /// double to add. Keep in mind the 100 nanosecond resolution of
405 /// <see cref="T:System.DateTime"/>.
407 /// <returns>A new <see cref="T:System.DateTime"/> value, that
408 /// results from adding <paramref name="milliseconds"/> to the specified
409 /// DateTime.</returns>
410 /// <exception cref="T:System.ArgumentOutOfRangeException">
411 /// The exception is thrown if the
412 /// <see cref="T:System.DateTime"/> return value is not in the
413 /// supported range of the Hijri calendar.
415 public override DateTime AddMilliseconds(DateTime time,
418 DateTime t = base.AddMilliseconds(time, milliseconds);
424 /// Overridden. Adds minutes to a given date.
426 /// <param name="time">The
427 /// <see cref="T:System.DateTime"/> to which to add
430 /// <param name="minutes">The number of minutes to add.</param>
431 /// <returns>A new <see cref="T:System.DateTime"/> value, that
432 /// results from adding <paramref name="minutes"/> to the specified
433 /// DateTime.</returns>
434 /// <exception cref="T:System.ArgumentOutOfRangeException">
435 /// The exception is thrown if the
436 /// <see cref="T:System.DateTime"/> return value is not in the
437 /// supported range of the Hijri calendar.
439 public override DateTime AddMinutes(DateTime time, int minutes) {
440 DateTime t = base.AddMinutes(time, minutes);
446 /// Overridden. Adds seconds to a given date.
448 /// <param name="time">The
449 /// <see cref="T:System.DateTime"/> to which to add
452 /// <param name="seconds">The number of seconds to add.</param>
453 /// <returns>A new <see cref="T:System.DateTime"/> value, that
454 /// results from adding <paramref name="seconds"/> 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
459 /// supported range of the Hijri calendar.
461 public override DateTime AddSeconds(DateTime time, int seconds) {
462 DateTime t = base.AddSeconds(time, seconds);
468 /// Overridden. Adds weeks to a given date.
470 /// <param name="time">The
471 /// <see cref="T:System.DateTime"/> to which to add
474 /// <param name="weeks">The number of weeks to add.</param>
475 /// <returns>A new <see cref="T:System.DateTime"/> value, that
476 /// results from adding <paramref name="weeks"/> to the specified
477 /// DateTime.</returns>
478 /// <exception cref="T:System.ArgumentOutOfRangeException">
479 /// The exception is thrown if the
480 /// <see cref="T:System.DateTime"/> return value is not in the
481 /// supported range of the Hijri calendar.
483 public override DateTime AddWeeks(DateTime time, int weeks) {
484 DateTime t = base.AddWeeks(time, weeks);
490 /// Overridden. Gives the hour of the specified time.
492 /// <param name="time">The
493 /// <see cref="T:System.DateTime"/> that specifies the
496 /// <returns>An integer that gives the hour of the specified time,
497 /// starting with 0.</returns>
498 /// <exception cref="T:System.ArgumentOutOfRangeException">
499 /// The exception is thrown if the
500 /// <see cref="T:System.DateTime"/> parameter is not in the
501 /// supported range of the Hijri calendar.
503 public override int GetHour(DateTime time) {
504 M_CheckDateTime(time);
505 return base.GetHour(time);
509 /// Overridden. Gives the milliseconds in the current second
510 /// of the specified time.
512 /// <param name="time">The
513 /// <see cref="T:System.DateTime"/> that specifies the
516 /// <returns>An integer that gives the milliseconds in the seconds
517 /// of the specified time, starting with 0.</returns>
518 /// <exception cref="T:System.ArgumentOutOfRangeException">
519 /// The exception is thrown if the
520 /// <see cref="T:System.DateTime"/> parameter is not in the
521 /// supported range of the Hijri calendar.
523 public override double GetMilliseconds(DateTime time) {
524 M_CheckDateTime(time);
525 return base.GetMilliseconds(time);
529 /// Overridden. Gives the minute of the specified time.
531 /// <param name="time">The
532 /// <see cref="T:System.DateTime"/> that specifies the
535 /// <returns>An integer that gives the minute of the specified time,
536 /// starting with 0.</returns>
537 /// <exception cref="T:System.ArgumentOutOfRangeException">
538 /// The exception is thrown if the
539 /// <see cref="T:System.DateTime"/> parameter is not in the
540 /// supported range of the Hijri calendar.
542 public override int GetMinute(DateTime time) {
543 M_CheckDateTime(time);
544 return base.GetMinute(time);
548 /// Overridden. Gives the second of the specified time.
550 /// <param name="time">The
551 /// <see cref="T:System.DateTime"/> that specifies the
554 /// <returns>An integer that gives the second of the specified time,
555 /// starting with 0.</returns>
556 /// <exception cref="T:System.ArgumentOutOfRangeException">
557 /// The exception is thrown if the
558 /// <see cref="T:System.DateTime"/> parameter is not in the
559 /// supported range of the Hijri calendar.
561 public override int GetSecond(DateTime time) {
562 M_CheckDateTime(time);
563 return base.GetMinute(time);
568 /// Overrideden. Adds months to a given date.
570 /// <param name="time">The
571 /// <see cref="T:System.DateTime"/> to which to add
574 /// <param name="months">The number of months to add.</param>
575 /// <returns>A new <see cref="T:System.DateTime"/> value, that
576 /// results from adding <paramref name="months"/> to the specified
577 /// DateTime.</returns>
578 /// <exception cref="T:System.ArgumentOutOfRangeException">
579 /// The exception is thrown if the
580 /// <see cref="T:System.DateTime"/> return value is not in the
581 /// supported range of the Hijri calendar.
583 public override DateTime AddMonths(DateTime time, int months) {
584 int rd = M_FromDateTime(time);
585 int day, month, year;
586 CCHijriCalendar.dmy_from_fixed(
587 out day, out month, out year, rd);
589 year += CCMath.div_mod(out month, month, 12);
590 rd = CCHijriCalendar.fixed_from_dmy(day, month, year);
591 M_CheckFixedHijri("time", rd);
592 DateTime t = M_ToDateTime(rd);
593 return t.Add(time.TimeOfDay);
597 /// Overrideden. Adds years to a given date.
599 /// <param name="time">The
600 /// <see cref="T:System.DateTime"/> to which to add
603 /// <param name="years">The number of years to add.</param>
604 /// <returns>A new <see cref="T:System.DateTime"/> value, that
605 /// results from adding <paramref name="years"/> to the specified
606 /// DateTime.</returns>
607 /// <exception cref="T:System.ArgumentOutOfRangeException">
608 /// The exception is thrown if the
609 /// <see cref="T:System.DateTime"/> return value is not in the
610 /// supported range of the Hijri calendar.
612 public override DateTime AddYears(DateTime time, int years) {
613 int rd = M_FromDateTime(time);
614 int day, month, year;
615 CCHijriCalendar.dmy_from_fixed(
616 out day, out month, out year, rd);
618 rd = CCHijriCalendar.fixed_from_dmy(day, month, year);
619 M_CheckFixedHijri("time", rd);
620 DateTime t = M_ToDateTime(rd);
621 return t.Add(time.TimeOfDay);
625 /// Overriden. Gets the day of the month from
626 /// <paramref name="time"/>.
628 /// <param name="time">The
629 /// <see cref="T:System.DateTime"/> that specifies a
632 /// <returns>An integer giving the day of months, starting with 1.
634 /// <exception cref="T:System.ArgumentOutOfRangeException">
635 /// The exception is thrown if the
636 /// <see cref="T:System.DateTime"/> parameter is not in the
637 /// supported range of the Hijri calendar.
639 public override int GetDayOfMonth(DateTime time) {
640 int rd = M_FromDateTime(time);
641 M_CheckFixedHijri("time", rd);
642 return CCHijriCalendar.day_from_fixed(rd);
646 /// Overriden. Gets the day of the week from the specified date.
648 /// <param name="time">The
649 /// <see cref="T:System.DateTime"/> that specifies a
652 /// <returns>An integer giving the day of months, starting with 1.
654 /// <exception cref="T:System.ArgumentOutOfRangeException">
655 /// The exception is thrown if the
656 /// <see cref="T:System.DateTime"/> parameter is not in the
657 /// supported range of the Hijri calendar.
659 public override DayOfWeek GetDayOfWeek(DateTime time) {
660 int rd = M_FromDateTime(time);
661 M_CheckFixedHijri("time", rd);
662 return (DayOfWeek)CCFixed.day_of_week(rd);
666 /// Overridden. Gives the number of the day in the year.
668 /// <param name="time">The
669 /// <see cref="T:System.DateTime"/> that specifies a
672 /// <returns>An integer representing the day of the year,
673 /// starting with 1.</returns>
674 /// <exception cref="T:System.ArgumentOutOfRangeException">
675 /// The exception is thrown if the
676 /// <see cref="T:System.DateTime"/> parameter is not in the
677 /// supported range of the Hijri calendar.
679 public override int GetDayOfYear(DateTime time) {
680 int rd = M_FromDateTime(time);
681 M_CheckFixedHijri("time", rd);
682 int year = CCHijriCalendar.year_from_fixed(rd);
683 int rd1_1 = CCHijriCalendar.fixed_from_dmy(1, 1, year);
684 return rd - rd1_1 + 1;
688 /// Overridden. Gives the number of days in the specified month
689 /// of the given year and era.
691 /// <param name="year">An integer that gives the year.
693 /// <param name="month">An integer that gives the month, starting
695 /// <param name="era">An intger that gives the era of the specified
697 /// <returns>An integer that gives the number of days of the
698 /// specified month.</returns>
699 /// <exception cref="T:System.ArgumentOutOfRangeException">
700 /// The exception is thrown, if <paramref name="month"/>,
701 /// <paramref name="year"/> ,or <paramref name="era"/> is outside
702 /// the allowed range.
704 public override int GetDaysInMonth(int year, int month, int era) {
705 M_CheckYME(year, month, ref era);
706 int rd1 = CCHijriCalendar.fixed_from_dmy(1, month, year);
707 int rd2 = CCHijriCalendar.fixed_from_dmy(1, month+1, year);
712 /// Overridden. Gives the number of days of the specified
713 /// year of the given era.
715 /// <param name="year">An integer that specifies the year.
717 /// <param name="era">An ineger that specifies the era.
719 /// <returns>An integer that gives the number of days of the
720 /// specified year.</returns>
721 /// <exception cref="T:System.ArgumentOutOfRangeExceiption">
722 /// The exception is thrown, if
723 /// <paramref name="year"/> is outside the allowed range.
725 public override int GetDaysInYear(int year, int era) {
726 M_CheckYE(year, ref era);
727 int rd1 = CCHijriCalendar.fixed_from_dmy(1, 1, year);
728 int rd2 = CCHijriCalendar.fixed_from_dmy(1, 1, year+1);
734 /// Overridden. Gives the era of the specified date.
736 /// <param name="time">The
737 /// <see cref="T:System.DateTime"/> that specifies a
740 /// <returns>An integer representing the era of the calendar.
742 /// <exception cref="T:System.ArgumentOutOfRangeException">
743 /// The exception is thrown if the
744 /// <see cref="T:System.DateTime"/> parameter is not in the
745 /// supported range of the Hijri calendar.
747 public override int GetEra(DateTime time) {
748 M_CheckDateTime(time);
752 public override int GetLeapMonth (int year, int era)
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 millisecond,
920 M_CheckYMDE(year, month, day, ref era);
921 M_CheckHMSM(hour, minute, second, millisecond);
922 int rd = CCHijriCalendar.fixed_from_dmy(day, month, year);
923 return M_ToDateTime(rd,
924 hour, minute, second, millisecond);
927 public override int ToFourDigitYear(int year)
929 return base.ToFourDigitYear (year);
933 public override CalendarAlgorithmType AlgorithmType {
935 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 protected override int DaysInYearBeforeMinSupportedYear {
962 } // class HijriCalendar
964 } // namespace System.Globalization