/// <summary> /// Constructs an instance with the Epoch Day. /// </summary> /// <param name="epochDay"> the epochDay </param> private HijrahDate(HijrahChronology ChronoLocalDate_Fields, long epochDay) { int[] dateInfo = ChronoLocalDate_Fields.Chrono.getHijrahDateInfo((int)epochDay); this.Chrono = ChronoLocalDate_Fields.Chrono; this.ProlepticYear = dateInfo[0]; this.MonthOfYear = dateInfo[1]; this.DayOfMonth = dateInfo[2]; }
//----------------------------------------------------------------------- /// <summary> /// Constructs an {@code HijrahDate} with the proleptic-year, month-of-year and /// day-of-month fields. /// </summary> /// <param name="chrono"> The chronology to create the date with </param> /// <param name="prolepticYear"> the proleptic year </param> /// <param name="monthOfYear"> the month of year </param> /// <param name="dayOfMonth"> the day of month </param> private HijrahDate(HijrahChronology ChronoLocalDate_Fields, int prolepticYear, int monthOfYear, int dayOfMonth) { // Computing the Gregorian day checks the valid ranges ChronoLocalDate_Fields.Chrono.getEpochDay(prolepticYear, monthOfYear, dayOfMonth); this.Chrono = ChronoLocalDate_Fields.Chrono; this.ProlepticYear = prolepticYear; this.MonthOfYear = monthOfYear; this.DayOfMonth = dayOfMonth; }
/// <summary> /// Returns a {@code HijrahDate} with the Chronology requested. /// <para> /// The year, month, and day are checked against the new requested /// HijrahChronology. If the chronology has a shorter month length /// for the month, the day is reduced to be the last day of the month. /// /// </para> /// </summary> /// <param name="chronology"> the new HijrahChonology, non-null </param> /// <returns> a HijrahDate with the requested HijrahChronology, non-null </returns> public HijrahDate WithVariant(HijrahChronology chronology) { if (ChronoLocalDate_Fields.Chrono == chronology) { return(this); } // Like resolvePreviousValid the day is constrained to stay in the same month int monthDays = chronology.GetDayOfYear(ProlepticYear, MonthOfYear); return(HijrahDate.Of(chronology, ProlepticYear, MonthOfYear, (DayOfMonth > monthDays) ? monthDays : DayOfMonth)); }
/// <summary> /// Returns a HijrahDate for the chronology and epochDay. </summary> /// <param name="chrono"> The Hijrah chronology </param> /// <param name="epochDay"> the epoch day </param> /// <returns> a HijrahDate for the epoch day; non-null </returns> internal static HijrahDate OfEpochDay(HijrahChronology ChronoLocalDate_Fields, long epochDay) { return(new HijrahDate(ChronoLocalDate_Fields.Chrono, epochDay)); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance of {@code HijrahDate} from the Hijrah proleptic year, /// month-of-year and day-of-month. /// </summary> /// <param name="prolepticYear"> the proleptic year to represent in the Hijrah calendar </param> /// <param name="monthOfYear"> the month-of-year to represent, from 1 to 12 </param> /// <param name="dayOfMonth"> the day-of-month to represent, from 1 to 30 </param> /// <returns> the Hijrah date, never null </returns> /// <exception cref="DateTimeException"> if the value of any field is out of range </exception> internal static HijrahDate Of(HijrahChronology ChronoLocalDate_Fields, int prolepticYear, int monthOfYear, int dayOfMonth) { return(new HijrahDate(ChronoLocalDate_Fields.Chrono, prolepticYear, monthOfYear, dayOfMonth)); }