Beispiel #1
0
    def test_nawruz(self):
        nawruz_official = {
            2015: 21,
            2016: 20,
            2017: 20,
            2018: 21,
            2019: 21,
            2020: 20,
            2021: 20,
            2022: 21,
            2023: 21,
            2024: 20,
            2025: 20,
            2026: 21,
            2027: 21,
            2028: 20,
            2029: 20,
            2030: 20,
            2031: 21,
            2032: 20,
            2033: 20,
            2034: 20,
            2035: 21,
            2036: 20,
            2037: 20,
            2038: 20,
            2039: 21,
            2040: 20,
            2041: 20,
            2042: 20,
            2043: 21,
            2044: 20,
            2045: 20,
            2046: 20,
            2047: 21,
            2048: 20,
            2049: 20,
            2050: 20,
            2051: 21,
            2052: 20,
            2053: 20,
            2054: 20,
            2055: 21,
            2056: 20,
            2057: 20,
            2058: 20,
            2059: 20,
            2060: 20,
            2061: 20,
            2062: 20,
            2063: 20,
            2064: 20
        }

        for year in nawruz_official:
            bahaiyear = year - 1844 + 1
            actual = bahai.to_gregorian(bahaiyear, 1, 1)
            expected = (year, 3, nawruz_official[year])
            self.assertEqual (expected, actual)
Beispiel #2
0
 def test_bahai(self):
     self.reflexive(bahai.from_jd, bahai.to_jd)
     self.assertEqual(bahai.from_gregorian(1844, 3, 21), (1, 1, 1))
     self.assertEqual(bahai.to_gregorian(1, 1, 1), (1844, 3, 21))
     self.assertEqual(bahai.month_length(1, 3), 19)
     self.assertEqual(bahai.month_length(1, 1), 19)
     self.assertEqual(bahai.month_length(4, 19), 5)
     self.assertEqual(bahai.month_length(5, 19), 4)
     self.assertEqual(self.jd, bahai.to_jd(*bahai.from_jd(self.jd)))
Beispiel #3
0
    def test_misc(self):
        pairs = {
            (2041, 11, 27): (198, 14, 6), # ascension of Abdu'l-Bahá 2041
            (2043, 11, 28): (200, 14, 6), # ascension of Abdu'l-Bahá 2043
            (2038, 3, 1): (194, 20, 1), # beginning of fast 2038
            (2039, 3, 2): (195, 20, 1), # beginning of fast 2039
            (2040, 3, 1): (196, 20, 1), # beginning of fast 2040
            (2041, 3, 1): (197, 20, 1), # beginning of fast 2041
            (2042, 3, 1): (198, 20, 1), # beginning of fast 2042
            (2043, 3, 2): (199, 20, 1), # beginning of fast 2043
            (2031, 10, 17): (188, 12, 2), #twin holy days, 2031
            (2031, 10, 18): (188, 12, 3)
        }

        for gregorian in pairs:
            badi = pairs[gregorian]

            actual_gregorian = bahai.to_gregorian(*badi)
            actual_badi = bahai.from_gregorian(*gregorian)

            self.assertEqual(actual_gregorian, gregorian)
            self.assertEqual(actual_badi, badi)
Beispiel #4
0
 def test_to_gregorian(self):
     for g, b in self.pairs.items():
         self.assertEqual(g, bahai.to_gregorian(*b))
Beispiel #5
0
def convertBahaiDateOperator( year, month, day ):
    return RPNDateTime( *bahai.to_gregorian( int( year ), int( month ), int( day ) ), dateOnly = True )
Beispiel #6
0
def convertBahaiDate( year, month, day ):
    return RPNDateTime( *bahai.to_gregorian( int( year ), int( month ), int( day ) ) )