Ejemplo n.º 1
0
 /// <summary>
 /// Convert Ethiopian Date into JDN(Julian Date Number).
 /// </summary>
 /// <returns>JDN number integer value.</returns>
 /// <param name="day">Day.</param>
 /// <param name="month">Month.</param>
 /// <param name="year">Year.</param>
 /// <param name="era">Era. Defines if it is `Amete miheret` or `Amete alem`,
 /// the Ethiopian equivalents to A.D and B.C respectively.
 /// Possible values are JDN_EPOCH_OFFSET.AMETE_MIHRET or JDN_EPOCH_OFFSET.AMETE_ALEM </param>
 public static int EthiopianToJDN(int day, int month, int year, int era = (int)JDN_EPOCH_OFFSET.AMETE_MIHRET)
 {
     if (!EtDateValidator.IsValidDayRange(day))
     {
         throw new InvalidDayException();
     }
     if (!EtDateValidator.IsValidMonthRange(month))
     {
         throw new InvalidMonthException();
     }
     if (!EtDateValidator.IsValidPagumeDayRange(day, month))
     {
         throw new InvalidPagumeDayException();
     }
     if (EtDateValidator.IsValid(day, month, year))
     {
         return((int)(era + (int)JDN_CONST._365 + (int)JDN_CONST._365 *
                      (year - (int)JDN_CONST._1) + Math.Floor((double)year /
                                                              (int)JDN_CONST._4) + (int)JDN_CONST._30 * month + day - (int)JDN_CONST._31));
     }
     //TODO fix this return
     return(0);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:EthiopianCalendar.Date"/> class.
 /// </summary>
 /// <param name="day">Day.</param>
 /// <param name="month">Month.</param>
 /// <param name="year">Year.</param>
 public Date(int day, int month, int year)
 {
     if (EtDateValidator.IsValid(day, month, year))
     {
         Day           = day;
         Month         = month;
         Year          = year;
         WeekDayNumber = Converter.EthiopianWeekDayNumber(day, month, year);
         Special       = Holiday.IsHoliday(this) ? Holiday.HolidayName(this) : null;
     }
     if (!EtDateValidator.IsValidDayRange(day))
     {
         throw new InvalidDayException();
     }
     if (!EtDateValidator.IsValidMonthRange(month))
     {
         throw new InvalidMonthException();
     }
     if (!EtDateValidator.IsValidPagumeDayRange(day, month))
     {
         throw new InvalidPagumeDayException();
     }
 }