Exemplo n.º 1
0
def hindu_lunar_holiday(l_month, l_day, gregorian_year):
    """Return the list of ordinal dates of occurrences of Hindu lunar
    month, month, day, day, in Gregorian year, 'gregorian_year'."""
    l_year = HinduLunarDate.fromordinal(
        GregorianDate.new_year(gregorian_year)).year
    date1 = hindu_date_occur(l_month, l_day, l_year)
    date2 = hindu_date_occur(l_month, l_day, l_year + 1)
    return list_range([date1, date2], GregorianDate.year_range(gregorian_year))
Exemplo n.º 2
0
def hindu_lunar_event(l_month, tithi, tee, gregorian_year):
    """Return the list of ordinal dates of occurrences of Hindu lunar tithi
    prior to sundial time, tee, in Hindu lunar month, l_month,
    in Gregorian year, 'gregorian_year'."""
    l_year = HinduLunarDate.fromordinal(
        GregorianDate.new_year(gregorian_year)).year
    date1 = hindu_tithi_occur(l_month, tithi, tee, l_year)
    date2 = hindu_tithi_occur(l_month, tithi, tee, l_year + 1)
    return list_range([date1, date2], GregorianDate.year_range(gregorian_year))
Exemplo n.º 3
0
 def in_gregorian(cls, coptic_month, coptic_day, gregorian_year):
     """Return the list of the ordinal dates of Coptic month 'coptic_month',
     day 'coptic_day' that occur in Gregorian year 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = cls.fromordinal(jan1).year
     date1 = CopticDate(y, coptic_month, coptic_day).toordinal()
     date2 = CopticDate(y + 1, coptic_month, coptic_day).toordinal()
     return list_range([date1, date2],
                       GregorianDate.year_range(gregorian_year))
Exemplo n.º 4
0
 def new_year(cls, gregorian_year):
     """Return ordinal date of Observational (classical)
     Nisan 1 occurring in Gregorian year, 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     equinox = solar_longitude_after(Season.SPRING, jan1)
     sset = JAFFA.universal_from_standard(
         JAFFA.sunset(int(math.floor(equinox))))
     return cls.phasis_on_or_after(
         int(math.floor(equinox)) - (14 if (equinox < sset) else 13), JAFFA)
Exemplo n.º 5
0
 def julian_in_gregorian(julian_month, julian_day, gregorian_year):
     """Return the list of the ordinal dates of Julian month 'julian_month', day
     'julian_day' that occur in Gregorian year 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y    = JulianDate.fromordinal(jan1).year
     y_prime = 1 if (y == -1) else (y + 1)
     date1 = JulianDate(y, julian_month, julian_day).toordinal()
     date2 = JulianDate(y_prime, julian_month, julian_day).toordinal()
     return list_range([date1, date2], GregorianDate.year_range(gregorian_year))
Exemplo n.º 6
0
def vietnamese_location(tee):
    """Return the location for Vietnamese calendar is Hanoi;
    varies with moment, tee. Time zone has changed over the years."""
    if (tee < GregorianDate.new_year(1968)):
        z = 8
    else:
        z = 7
    return Location(angle(21, 2, 0), angle(105, 51, 0), 12,
                    Clock.days_from_hours(z))
Exemplo n.º 7
0
 def yahrzeit_in_gregorian(self, gregorian_year):
     """Return the list of the ordinal dates of death date death_date (yahrzeit)
     that occur in Gregorian year 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = HebrewDate.fromordinal(jan1).year
     date1 = self.yahrzeit(y)
     date2 = self.yahrzeit(y + 1)
     return list_range([date1, date2],
                       GregorianDate.year_range(gregorian_year))
Exemplo n.º 8
0
 def birthday_in_gregorian(self, gregorian_year):
     """Return the list of the ordinal dates of Hebrew birthday
     birthday that occur in Gregorian 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = HebrewDate.fromordinal(jan1).year
     date1 = self.birthday(y)
     date2 = self.birthday(y + 1)
     return list_range([date1, date2],
                       GregorianDate.year_range(gregorian_year))
Exemplo n.º 9
0
 def in_gregorian(cls, month, day, gregorian_year):
     """Return list of the ordinal dates of Islamic month 'month', day 'day' that
     occur in Gregorian year 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = cls.fromordinal(jan1).year
     date1 = IslamicDate(y, month, day).toordinal()
     date2 = IslamicDate(y + 1, month, day).toordinal()
     date3 = IslamicDate(y + 2, month, day).toordinal()
     return list_range([date1, date2, date3],
                       GregorianDate.year_range(gregorian_year))
Exemplo n.º 10
0
def hindu_lunar_new_year(g_year):
    """Return the ordinal date of Hindu lunisolar new year in
    Gregorian year, g_year."""
    jan1 = GregorianDate.new_year(g_year)
    mina = hindu_solar_longitude_at_or_after(330, jan1)
    new_moon = HinduLunarDate.day_at_or_after(1, mina)
    h_day = int(math.floor(new_moon))
    critical = HinduDate.sunrise(h_day)
    return (h_day + (0 if
                     ((new_moon < critical) or (HinduLunarDate.day_from_moment(
                         HinduDate.sunrise(h_day + 1)) == 2)) else 1))
Exemplo n.º 11
0
def astronomical_easter(g_year):
    """Return date of (proposed) astronomical Easter in Gregorian
    year, g_year."""
    jan1 = GregorianDate.new_year(g_year)
    equinox = solar_longitude_after(Season.SPRING, jan1)
    paschal_moon = int(
        math.floor(
            JERUSALEM.apparent_from_local(
                JERUSALEM.local_from_universal(
                    lunar_phase_at_or_after(MoonPhase.FULL, equinox)))))
    # Return the Sunday following the Paschal moon.
    return DayOfWeek(DayOfWeek.SUNDAY).after(paschal_moon)
Exemplo n.º 12
0
 def tzom_tevet(cls, gregorian_year):
     """Return the list of ordinal dates for Tzom Tevet (Tevet 10) that
     occur in Gregorian year 'gregorian_year'. It can occur 0, 1 or 2 times per
     Gregorian year."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = HebrewDate.fromordinal(jan1).year
     d1 = HebrewDate(y, HebrewMonth.TEVET, 10).toordinal()
     d1 = d1 + (1 if weekday_fromordinal(d1) == DayOfWeek.SATURDAY else 0)
     d2 = HebrewDate(y + 1, HebrewMonth.TEVET, 10).toordinal()
     d2 = d2 + (1 if weekday_fromordinal(d2) == DayOfWeek.SATURDAY else 0)
     dates = [d1, d2]
     return list_range(dates, GregorianDate.year_range(gregorian_year))
Exemplo n.º 13
0
 def in_gregorian(cls, month, day, gregorian_year):
     """Return list of the ordinal dates of Hebrew month, 'month', day, 'day',
     that occur in Gregorian year 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = HebrewDate.fromordinal(jan1).year
     date1 = HebrewDate(y, month, day).toordinal()
     date2 = HebrewDate(y + 1, month, day).toordinal()
     # Hebrew and Gregorian calendar are aligned but certain
     # holidays, i.e. Tzom Tevet, can fall on either side of Jan 1.
     # So we can have 0, 1 or 2 occurences of that holiday.
     dates = [date1, date2]
     return list_range(dates, GregorianDate.year_range(gregorian_year))
Exemplo n.º 14
0
def mesha_samkranti(g_year):
    """Return the ordinal moment of Mesha samkranti (Vernal equinox)
    in Gregorian year, g_year."""
    jan1 = GregorianDate.new_year(g_year)
    return hindu_solar_longitude_at_or_after(0, jan1)
Exemplo n.º 15
0
from mpmath import mpf, pi
import math
from jetblack.calendars.datemath import MonthOfYear
from jetblack.calendars.timemath import Clock
from jetblack.calendars.systems.gregorian import GregorianDate
from jetblack.calendars.utils import poly, signum
from jetblack.calendars.trigonometry import angle, sin_degrees, cos_degrees, tan_degrees, arcsin_degrees, arctan_degrees, secs

J2000 = Clock.days_from_hours(mpf(12)) + GregorianDate.new_year(2000)


def zone_from_longitude(phi):
    """Return the difference between UT and local mean time at longitude
    'phi' as a fraction of a day."""
    return phi / 360


def ephemeris_correction(tee):
    """Return Dynamical Time minus Universal Time (in days) for
    moment, tee.  Adapted from "Astronomical Algorithms"
    by Jean Meeus, Willmann_Bell, Inc., 1991."""
    year = GregorianDate.to_year(int(math.floor(tee)))
    c = GregorianDate.date_difference(
        GregorianDate(1900, MonthOfYear.JANUARY, 1),
        GregorianDate(year, MonthOfYear.JULY, 1)) / mpf(36525)
    if 1988 <= year <= 2019:
        return 1 / 86400 * (year - 1933)
    elif 1900 <= year <= 1987:
        return poly(c, [
            mpf(-0.00002),
            mpf(0.000297),
Exemplo n.º 16
0
 def is_long_year(cls, iso_year):
     """Return True if ISO year 'iso_year' is a long (53-week) year."""
     jan1 = weekday_fromordinal(GregorianDate.new_year(iso_year))
     dec31 = weekday_fromordinal(GregorianDate.year_end(iso_year))
     return jan1 == DayOfWeek.THURSDAY or dec31 == DayOfWeek.THURSDAY