示例#1
0
def hindu_lunar_holiday(l_month, l_day, gregorian_year):
    """Return the list of fixed dates of occurrences of Hindu lunar
    month, month, day, day, in Gregorian year, 'gregorian_year'."""
    l_year = HinduLunarDate.from_fixed(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))
示例#2
0
 def yahrzeit_in_gregorian(self, gregorian_year):
     """Return the list of the fixed dates of death date death_date (yahrzeit)
     that occur in Gregorian year 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = HebrewDate.from_fixed(jan1).year
     date1 = self.yahrzeit(y)
     date2 = self.yahrzeit(y + 1)
     return list_range([date1, date2], GregorianDate.year_range(gregorian_year))
示例#3
0
def hindu_lunar_event(l_month, tithi, tee, gregorian_year):
    """Return the list of fixed 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.from_fixed(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))
示例#4
0
 def birthday_in_gregorian(self, gregorian_year):
     """Return the list of the fixed dates of Hebrew birthday
     birthday that occur in Gregorian 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = HebrewDate.from_fixed(jan1).year
     date1 = self.birthday(y)
     date2 = self.birthday(y + 1)
     return list_range([date1, date2], GregorianDate.year_range(gregorian_year))
示例#5
0
 def in_gregorian(cls, c_month, c_day, g_year):
     """Return the list of the fixed dates of Coptic month 'c_month',
     day 'c_day' that occur in Gregorian year 'g_year'."""
     jan1 = GregorianDate.new_year(g_year)
     y = cls.from_fixed(jan1).year
     date1 = CopticDate(y, c_month, c_day).to_fixed()
     date2 = CopticDate(y + 1, c_month, c_day).to_fixed()
     return list_range([date1, date2], GregorianDate.year_range(g_year))
示例#6
0
 def in_gregorian(cls, month, day, gregorian_year):
     """Return list of the fixed dates of Islamic month 'month', day 'day' that
     occur in Gregorian year 'gregorian_year'."""
     jan1  = GregorianDate.new_year(gregorian_year)
     y     = cls.from_fixed(jan1).year
     date1 = IslamicDate(y, month, day).to_fixed()
     date2 = IslamicDate(y + 1, month, day).to_fixed()
     date3 = IslamicDate(y + 2, month, day).to_fixed()
     return list_range([date1, date2, date3], GregorianDate.year_range(gregorian_year))
示例#7
0
 def julian_in_gregorian(j_month, j_day, g_year):
     """Return the list of the fixed dates of Julian month 'j_month', day
     'j_day' that occur in Gregorian year 'g_year'."""
     jan1 = GregorianDate.new_year(g_year)
     y    = JulianDate.from_fixed(jan1).year
     y_prime = 1 if (y == -1) else (y + 1)
     date1 = JulianDate(y, j_month, j_day).to_fixed()
     date2 = JulianDate(y_prime, j_month, j_day).to_fixed()
     return list_range([date1, date2], GregorianDate.year_range(g_year))
示例#8
0
 def tzom_tevet(cls, gregorian_year):
     """Return the list of fixed 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.from_fixed(jan1).year
     d1 = HebrewDate(y, HebrewMonth.TEVET, 10).to_fixed()
     d1 = d1 + 1 if DayOfWeek.from_fixed(d1) == DayOfWeek.Saturday else d1
     d2 = HebrewDate(y + 1, HebrewMonth.TEVET, 10).to_fixed()
     d2 = d2 + 1 if DayOfWeek.from_fixed(d2) == DayOfWeek.Saturday else d2
     dates = [d1, d2]
     return list_range(dates, GregorianDate.year_range(gregorian_year))
示例#9
0
 def in_gregorian(cls, month, day, gregorian_year):
     """Return list of the fixed dates of Hebrew month, 'month', day, 'day',
     that occur in Gregorian year 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     y = HebrewDate.from_fixed(jan1).year
     date1 = HebrewDate(y, month, day).to_fixed()
     date2 = HebrewDate(y + 1, month, day).to_fixed()
     # 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))
示例#10
0
 def location(cls, tee):
     """Return location of Beijing; time zone varies with time, tee."""
     year = GregorianDate.to_year(ifloor(tee))
     if (year < 1929):
         return Location(angle(39, 55, 0), angle(116, 25, 0), 43.5, Clock.days_from_hours(1397/180))
     else:
         return Location(angle(39, 55, 0), angle(116, 25, 0), 43.5, Clock.days_from_hours(8))
示例#11
0
 def dragon_festival(cls, gregorian_year):
     """Return fixed date of the Dragon Festival occurring in Gregorian
     year 'gregorian_year'."""
     elapsed_years = 1 + gregorian_year - GregorianDate.to_year(cls.EPOCH)
     cycle = 1 + quotient(elapsed_years - 1, 60)
     year = amod(elapsed_years, 60)
     return ChineseDate(cycle, year, 5, False, 5).to_fixed()
示例#12
0
 def new_year(cls, gregorian_year):
     """Return fixed date of Observational (classical)
     Nisan 1 occurring in Gregorian year, 'gregorian_year'."""
     jan1 = GregorianDate.new_year(gregorian_year)
     equinox = Solar.solar_longitude_after(Astro.SPRING, jan1)
     sset = JAFFA.universal_from_standard(JAFFA.sunset(ifloor(equinox)))
     return cls.phasis_on_or_after(ifloor(equinox) - (14 if (equinox < sset) else 13), JAFFA)
示例#13
0
 def feast_of_ridvan(cls, gregorian_year):
     """Return Fixed date of Feast of Ridvan in Gregorian year year, 'gregorian_year'."""
     years = gregorian_year - GregorianDate.to_year(cls.EPOCH)
     major = 1 + quotient(years, 361)
     cycle = 1 + quotient(mod(years, 361), 19)
     year = 1 + mod(years, 19)
     return FutureBahaiDate(major, cycle, year, 2, 13).to_fixed()
示例#14
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))
示例#15
0
 def to_fixed(self):
     """Return fixed date equivalent to Observational Hebrew date."""
     year1 = self.year - 1 if self.month >= HebrewMonth.TISHRI else self.year
     start = HebrewDate(year1, HebrewMonth.NISAN, 1).to_fixed()
     g_year = GregorianDate.to_year(start + 60)
     new_year = self.new_year(g_year)
     midmonth = new_year + iround(29.5 * (self.month - 1)) + 15
     return JAFFA.phasis_on_or_before(midmonth) + self.day - 1
示例#16
0
 def omer(cls, fixed_date):
     """Return the number of elapsed weeks and days in the omer at date fixed_date.
     Throws ValueError if that date does not fall during the omer."""
     c = fixed_date - cls.passover(GregorianDate.to_year(fixed_date))
     if 1 <= c <= 49:
         return [quotient(c, 7), mod(c, 7)]
     else:
         raise ValueError("Date does not fall within omer")
示例#17
0
 def to_fixed(self):
     """Return fixed date equivalent to the Bahai date, b_date."""
     g_year = (361 * (self.major - 1) +
               19 * (self.cycle - 1)  +
               self.year - 1 +
               GregorianDate.to_year(self.EPOCH))
     if (self.month == self.AYYAM_I_HA):
         elapsed_months = 342
     elif (self.month == 19):
         if (GregorianDate.is_leap_year(g_year + 1)):
             elapsed_months = 347
         else:
             elapsed_months = 346
     else:
         elapsed_months = 19 * (self.month - 1)
 
     return GregorianDate(g_year, MonthOfYear.March, 20).to_fixed() + elapsed_months + self.day
示例#18
0
 def from_fixed(cls, date):
     """Return the ISO date corresponding to the fixed date 'date'."""
     approx = GregorianDate.to_year(date - 3)
     year   = (approx +
               1 if date >= IsoDate(approx + 1, 1, 1).to_fixed()
               else approx)
     week   = 1 + quotient(date - IsoDate(year, 1, 1).to_fixed(), 7)
     day    = amod(date - rd(0), 7)
     return IsoDate(year, week, day)
示例#19
0
 def ephemeris_correction(cls, 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(ifloor(tee))
     c = GregorianDate.date_difference(GregorianDate(1900, JulianMonth.January, 1), GregorianDate(year, JulianMonth.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), mpf(0.025184), mpf(-0.181133), mpf(0.553040), mpf(-0.861938), mpf(0.677066), mpf(-0.212591)])
     elif 1800 <= year <= 1899:
         return poly(c, [mpf(-0.000009), mpf(0.003844), mpf(0.083563), mpf(0.865736), mpf(4.867575), mpf(15.845535), mpf(31.332267), mpf(38.291999), mpf(28.316289), mpf(11.636204), mpf(2.043794)])
     elif 1700 <= year <= 1799:
         return 1/86400 * poly(year - 1700, [8.118780842, -0.005092142, 0.003336121, -0.0000266484])
     elif 1620 <= year <= 1699:
         return 1/86400 * poly(year - 1600, [mpf(196.58333), mpf(-4.0675), mpf(0.0219167)])
     else:
         x = Clock.days_from_hours(mpf(12)) + GregorianDate.date_difference(GregorianDate(1810, JulianMonth.January, 1), GregorianDate(year, JulianMonth.January, 1))
         return 1/86400 * (((x * x) / mpf(41048480)) - 15)
示例#20
0
def japanese_location(tee):
    """Return the location for Japanese calendar; varies with moment, tee."""
    year = GregorianDate.to_year(ifloor(tee))
    if (year < 1888):
        # Tokyo (139 deg 46 min east) local time
        loc = Location(mpf(35.7), angle(139, 46, 0), 24, Clock.days_from_hours(9 + 143/450))
    else:
        # Longitude 135 time zone
        loc = Location(35, 135, 0, Clock.days_from_hours(9))
    return loc
示例#21
0
 def from_fixed(cls, fixed_date):
     """Return Observational Hebrew date (year month day)
     corresponding to fixed date, 'fixed_date'."""
     crescent = JAFFA.phasis_on_or_before(fixed_date)
     g_year = GregorianDate.to_year(fixed_date)
     ny = cls.new_year(g_year)
     new_year = cls.new_year(g_year - 1) if (fixed_date < ny) else ny
     month = iround((crescent - new_year) / 29.5) + 1
     year = HebrewDate.from_fixed(new_year).year + (1 if month >= HebrewMonth.TISHRI else 0)
     day = fixed_date - crescent + 1
     return HebrewObservationalDate(year, month, day)
示例#22
0
 def testEaster(self):
     knownDates = {
         -214193: JulianDate(-586, 4, 3),
         -61387: JulianDate(-168, 4, 1),
         25469: JulianDate(70, 4, 13),
         49217: JulianDate(135, 4, 17),
         171307: JulianDate(470, 4, 6),
         210155: JulianDate(576, 4, 7),
         253427: JulianDate(694, 4, 22),
         369740: JulianDate(1013, 4, 11),
         400085: JulianDate(1096, 4, 19),
         434355: JulianDate(1190, 4, 1),
         452605: JulianDate(1240, 4, 22),
         470160: JulianDate(1288, 4, 4),
         473837: JulianDate(1298, 4, 13),
         507850: JulianDate(1391, 4, 3),
         524156: JulianDate(1436, 4, 17),
         544676: JulianDate(1492, 5, 1),
         567118: JulianDate(1553, 4, 12),
         569477: JulianDate(1560, 4, 24),
         601716: JulianDate(1648, 4, 12),
         613424: JulianDate(1680, 4, 21),
         626596: JulianDate(1716, 4, 12),
         645554: JulianDate(1768, 4, 10),
         664224: JulianDate(1819, 4, 18),
         671401: JulianDate(1839, 4, 7),
         694799: JulianDate(1903, 4, 19),
         704424: JulianDate(1929, 5, 5),
         708842: JulianDate(1941, 4, 20),
         709409: JulianDate(1943, 4, 25),
         709580: JulianDate(1943, 4, 25),
         727274: JulianDate(1992, 4, 26),
         728714: JulianDate(1996, 4, 14),
         744313: JulianDate(2038, 4, 25),
         764652: JulianDate(2094, 4, 11)
     }
     
     for (fixed_date, julian_date) in knownDates.iteritems():
         GregorianDate.from_fixed(fixed_date)
         self.assertEqual(fixed_date, julian_date.to_fixed(), "Convert to fixed")
         self.assertEqual(JulianDate.from_fixed(fixed_date), julian_date, "Convert from fixed")
示例#23
0
    def yom_ha_zikkaron(cls, gregorian_year):
        """Return fixed date of Yom ha_Zikkaron occurring in Gregorian
        year 'gregorian_year'."""
        hebrew_year = gregorian_year - GregorianDate.to_year(cls.EPOCH)
        iyyar4 = HebrewDate(hebrew_year, HebrewMonth.IYYAR, 4).to_fixed()

        if DayOfWeek.from_fixed(iyyar4) in (DayOfWeek.Thursday, DayOfWeek.Friday):
            return DayOfWeek.Wednesday.before(iyyar4)
        elif DayOfWeek.Sunday == DayOfWeek.from_fixed(iyyar4):
            return iyyar4 + 1
        else:
            return iyyar4
示例#24
0
def hindu_lunar_new_year(g_year):
    """Return the fixed 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    = ifloor(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))
示例#25
0
    def from_fixed(cls, fixed_date):
        """Return Bahai date [major, cycle, year, month, day] corresponding
        to fixed date, 'fixed_date'."""
        g_year = GregorianDate.to_year(fixed_date)
        start  = GregorianDate.to_year(cls.EPOCH)
        years  = (g_year - start -
                  (1 if (fixed_date <= 
                      GregorianDate(g_year, MonthOfYear.March, 20).to_fixed()) else 0))
        major  = 1 + quotient(years, 361)
        cycle  = 1 + quotient(mod(years, 361), 19)
        year   = 1 + mod(years, 19)
        days   = fixed_date - WesternBahaiDate(major, cycle, year, 1, 1).to_fixed()

        # month
        if fixed_date >= WesternBahaiDate(major, cycle, year, 19, 1).to_fixed():
            month = 19
        elif fixed_date >= WesternBahaiDate(major, cycle, year, cls.AYYAM_I_HA, 1).to_fixed():
            month = cls.AYYAM_I_HA
        else:
            month = 1 + quotient(days, 19)
    
        day = fixed_date + 1 - WesternBahaiDate(major, cycle, year, month, 1).to_fixed()
    
        return WesternBahaiDate(major, cycle, year, month, day)
示例#26
0
 def testKnownDates(self):
     
     knownDates = {
         -214193 : GregorianDate(-586, 7, 24),
         -61387 : GregorianDate(-168, 12, 5),
         25469 : GregorianDate(70, 9, 24),
         49217 : GregorianDate(135, 10, 2),
         171307 : GregorianDate(470, 1, 8),
         210155 : GregorianDate(576, 5, 20),
         253427 : GregorianDate(694, 11, 10),
         369740 : GregorianDate(1013, 4, 25),
         400085 : GregorianDate(1096, 5, 24),
         434355 : GregorianDate(1190, 3, 23),
         452605 : GregorianDate(1240, 3, 10),
         470160 : GregorianDate(1288, 4, 2),
         473837 : GregorianDate(1298, 4, 27),
         507850 : GregorianDate(1391, 6, 12),
         524156 : GregorianDate(1436, 2, 3),
         544676 : GregorianDate(1492, 4, 9),
         567118 : GregorianDate(1553, 9, 19),
         569477 : GregorianDate(1560, 3, 5),
         601716 : GregorianDate(1648, 6, 10),
         613424 : GregorianDate(1680, 6, 30),
         626596 : GregorianDate(1716, 7, 24),
         645554 : GregorianDate(1768, 6, 19),
         664224 : GregorianDate(1819, 8, 2),
         671401 : GregorianDate(1839, 3, 27),
         694799 : GregorianDate(1903, 4, 19),
         704424 : GregorianDate(1929, 8, 25),
         708842 : GregorianDate(1941, 9, 29),
         709409 : GregorianDate(1943, 4, 19),
         709580 : GregorianDate(1943, 10, 7),
         727274 : GregorianDate(1992, 3, 17),
         728714 : GregorianDate(1996, 2, 25),
         744313 : GregorianDate(2038, 11, 10),
         764652 : GregorianDate(2094, 7, 18)
     }
     
     for (fixed_date, gregorian_date) in knownDates.iteritems():
         self.assertEqual(fixed_date, gregorian_date.to_fixed(), "Convert to fixed")
         self.assertEqual(GregorianDate.from_fixed(fixed_date), gregorian_date, "Convert from fixed")
示例#27
0
 def tumpek(cls, g_year):
     """Return the occurrences of Tumpek (14th day of Pawukon and every
     35th subsequent day) within Gregorian year g_year."""
     year = GregorianDate.year_range(g_year)
     cap_Delta = cls.day_from_fixed(0)
     return cls.positions_in_range(14, 35, cap_Delta, year)
示例#28
0
 def kajeng_keliwon(cls, g_year):
     """Return the occurrences of Kajeng Keliwon (9th day of each
     15_day subcycle of Pawukon) in Gregorian year g_year."""
     year = GregorianDate.year_range(g_year)
     cap_Delta = cls.day_from_fixed(0)
     return cls.positions_in_range(9, 15, cap_Delta, year)
示例#29
0
def sacred_wednesdays(g_year):
    """Return the list of Wednesdays in Gregorian year, g_year,
    that are day 8 of Hindu lunar months."""
    return sacred_wednesdays_in_range(GregorianDate.year_range(g_year))
示例#30
0
def mesha_samkranti(g_year):
    """Return the fixed 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)