Ejemplo n.º 1
0
 def from_fixed(cls, fixed_date):
     """Return the Roman name corresponding to fixed fixed_date 'fixed_date'."""
     julian_date = JulianDate.from_fixed(fixed_date)
     month_prime = amod(1 + julian_date.month, 12)
     year_prime  = (julian_date.year if month_prime != 1 
                    else (julian_date.year + 1 if (julian_date.year != -1) else 1))
     kalends1 = RomanDate(year_prime, month_prime, Event.Kalends, 1, False).to_fixed()
 
     if julian_date.day == 1:
         return RomanDate(julian_date.year, julian_date.month, Event.Kalends, 1, False)
     elif julian_date.day <= cls.nones_of_month(julian_date.month):
         return RomanDate(julian_date.year,
                          julian_date.month,
                          Event.Nones, 
                          cls.nones_of_month(julian_date.month) - julian_date.day + 1,
                          False)
     elif julian_date.day <= cls.ides_of_month(julian_date.month):
         return RomanDate(julian_date.year,
                          julian_date.month,
                          Event.Ides,
                          cls.ides_of_month(julian_date.month) - julian_date.day + 1,
                          False)
     elif (julian_date.month != MonthOfYear.February) or not julian_date.is_leap_year(julian_date.year):
         return RomanDate(year_prime,
                          month_prime,
                          Event.Kalends,
                          kalends1 - fixed_date + 1,
                          False)
     elif julian_date.day < 25:
         return RomanDate(julian_date.year, MonthOfYear.March, Event.Kalends, 30 - julian_date.day, False)
     else:
         return RomanDate(julian_date.year, MonthOfYear.March, Event.Kalends, 31 - julian_date.day, julian_date.day == 25)
Ejemplo n.º 2
0
 def to_fixed(self):
     """Return the fixed date."""
     return ({Event.Kalends: JulianDate(self.year, self.month, 1).to_fixed(),
              Event.Nones:   JulianDate(self.year, self.month, self.nones_of_month(self.month)).to_fixed(),
              Event.Ides:    JulianDate(self.year, self.month, self.ides_of_month(self.month)).to_fixed()
              }[self.event] -
             self.count +
             (0 if (JulianDate.is_leap_year(self.year) and
                    (self.month == MonthOfYear.March) and
                    (self.event == Event.Kalends) and
                    (16 >= self.count >= 6))
              else 1) +
             (1 if self.leap else 0))
Ejemplo n.º 3
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")
Ejemplo n.º 4
0
 def testLeapYear(self):
     self.assertTrue(JulianDate.is_leap_year(2000))
     self.assertTrue(JulianDate.is_leap_year(1900))
Ejemplo n.º 5
0
 def testConversionFromFixed(self):
     self.assertEqual(JulianDate.from_fixed(self.testvalue), JulianDate(1945, MonthOfYear.October, 30))
Ejemplo n.º 6
0
    return ifloor(mod((HinduSolarDate.longitude(date) + HinduLunarDate.longitude(date)) / angle(0, 800, 0), 27)) + 1

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))

def sacred_wednesdays_in_range(range):
    """Return the list of Wednesdays within range of dates
    that are day 8 of Hindu lunar months."""
    a      = range[0]
    b      = range[1]
    wed    = DayOfWeek.Wednesday.on_or_after(a)
    h_date = HinduLunarDate.from_fixed(wed)
    ell  = [wed] if (h_date.day == 8) else []
    if is_in_range(wed, range):
        ell[:0] = sacred_wednesdays_in_range([wed + 1, b])
        return ell
    else:
        return []

SIDEREAL_START = Astro.precession(HinduDate.UJJAIN.universal_from_local(mesha_samkranti(JulianDate.ce(285))))

def sidereal_solar_longitude(tee):
    """Return sidereal solar longitude at moment, tee."""
    return mod(Solar.solar_longitude(tee) - Astro.precession(tee) + SIDEREAL_START, 360)

def sidereal_lunar_longitude(tee):
    """Return sidereal lunar longitude at moment, tee."""
    return mod(Lunar.lunar_longitude(tee) - Astro.precession(tee) + SIDEREAL_START, 360)