Пример #1
0
 def fromordinal(cls, ordinal):
     """Return the Astronomical Hindu (Tamil) solar date equivalent to
     ordinal date, 'ordinal'."""
     critical = cls.sunset(ordinal)
     month = sidereal_zodiac(critical)
     year = cls.calendar_year(critical) - HinduSolarDate.SOLAR_ERA
     approx = ordinal - 3 - (
         (int(math.floor(sidereal_solar_longitude(critical)))) % 30)
     begin = next_int(approx, lambda i:
                      (sidereal_zodiac(cls.sunset(i)) == month))
     day = ordinal - begin + 1
     return HinduAstroSolar(year, month, day)
Пример #2
0
 def fromordinal(cls, ordinal):
     """Return  Hebrew (year month day) corresponding to ordinal date 'ordinal'.
     # The fraction can be approximated by 365.25."""
     approx = int(
         math.floor((ordinal - cls.EPOCH) / Fraction(35975351, 98496))) + 1
     year = final_int(approx - 1, lambda y: cls.new_year(y) <= ordinal)
     start = HebrewMonth.TISHRI if ordinal < HebrewDate(
         year, HebrewMonth.NISAN, 1).toordinal() else HebrewMonth.NISAN
     month = next_int(
         start, lambda m: ordinal <= HebrewDate(
             year, m, cls.last_day_of_month(m, year)).toordinal())
     day = ordinal - HebrewDate(year, month, 1).toordinal() + 1
     return HebrewDate(year, month, day)
Пример #3
0
def hindu_date_occur(l_month, l_day, l_year):
    """Return the ordinal date of occurrence of Hindu lunar month, l_month,
    day, l_day, in Hindu lunar year, l_year, taking leap and
    expunged days into account.  When the month is
    expunged, then the following month is used."""
    lunar = HinduLunarDate(l_year, l_month, False, l_day, False)
    ttry = lunar.toordinal()
    mid = HinduLunarDate.fromordinal((ttry - 5) if (l_day > 15) else ttry)
    expunged = l_month != mid.month
    l_date = HinduLunarDate(mid.year, mid.month, mid.leap_month, l_day, False)
    if (expunged):
        return next_int(
            ttry, lambda d: (not is_hindu_lunar_on_or_before(
                HinduLunarDate.fromordinal(d), l_date))) - 1
    elif (l_day != HinduLunarDate.fromordinal(ttry).day):
        return ttry - 1
    else:
        return ttry
Пример #4
0
 def new_year_on_or_before(cls, ordinal):
     """Return ordinal date of French Revolutionary New Year on or
        before ordinal, ordinal."""
     approx = estimate_prior_solar_longitude(Season.AUTUMN, cls.midnight_in_paris(ordinal))
     return next_int(ifloor(approx) - 1, lambda day: Season.AUTUMN <= solar_longitude(cls.midnight_in_paris(day)))
Пример #5
0
def new_moon_at_or_after(tee):
    """Return the moment UT of first new moon at or after moment, tee."""
    t0 = nth_new_moon(0)
    phi = lunar_phase(tee)
    n = iround((tee - t0) / MEAN_SYNODIC_MONTH - phi / 360)
    return nth_new_moon(next_int(n, lambda k: nth_new_moon(k) >= tee))
Пример #6
0
 def new_year_on_or_before(cls, date):
     """Return the ordinal date of Astronomical Persian New Year on or
     before ordinal date, ordinal."""
     approx = estimate_prior_solar_longitude(Season.SPRING, cls.midday_in_tehran(date))
     return next_int(int(math.floor(approx)) - 1, lambda day: (solar_longitude(cls.midday_in_tehran(day)) <= (Season.SPRING + 2)))