示例#1
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)))
示例#2
0
 def test_returntype(self):
     self.assertSequenceType(bahai.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(coptic.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(hebrew.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(islamic.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(indian_civil.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(iso.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(julian.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(persian.from_gregorian(2020, 6, 4), int)
示例#3
0
def getBahaiCalendarDateNameOperator( n ):
    date = bahai.from_gregorian( n.year, n.month, n.day )

    result = bahaiDays[ n.weekday( ) ] + ', ' + bahaiMonths[ date[ 1 ] - 1 ] + \
           ' ' + str( date[ 2 ] ) + ', '

    if date[ 0 ] >= 1:
        result += 'Year ' + bahaiYears[ date[ 0 ] % 19 - 1 ] + ' of the ' + \
                  getOrdinalName( ( date[ 0 ] // 19 ) + 1 ) + ' Vahid of the ' + \
                  getOrdinalName( ( date[ 0 ] // 361 ) + 1 ) + ' Kull-i-Shay\'' + \
                  ' (Year ' + str( date[ 0 ] ) + ')'
    else:
        result += str( date[ 0 ] )

    return result
示例#4
0
文件: rpnCalendar.py 项目: flawr/rpn
def getBahaiCalendarDateName( n ):
    if not isinstance( n, RPNDateTime ):
        raise ValueError( 'time type required for this operator' )

    date = bahai.from_gregorian( n.year, n.month, n.day )

    result = bahaiDays[ n.weekday( ) ] + ', ' + bahaiMonths[ date[ 1 ] - 1 ] + \
           ' ' + str( date[ 2 ] ) + ', '

    print( date )

    if date[ 0 ] >= 1:
        result += 'Year ' + bahaiYears[ date[ 0 ] % 19 - 1 ] + ' of the ' + \
                  getOrdinalName( ( date[ 0 ] / 19 ) + 1 ) + ' Vahid of the ' + \
                  getOrdinalName( ( date[ 0 ] / 361 ) + 1 ) + ' Kull-i-Shay\'' + \
                  ' (Year ' + str( date[ 0 ] ) + ')'
    else:
        result += str( date[ 0 ] )

    return result
示例#5
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)
示例#6
0
 def test_from_gregorian(self):
     for g, b in self.pairs.items():
         self.assertEqual(b, bahai.from_gregorian(*g))
示例#7
0
def getBahaiCalendarDateOperator( n ):
    return list( bahai.from_gregorian( n.year, n.month, n.day ) )
示例#8
0
文件: rpnCalendar.py 项目: flawr/rpn
def getBahaiCalendarDate( n ):
    if not isinstance( n, RPNDateTime ):
        raise ValueError( 'time type required for this operator' )

    return list( bahai.from_gregorian( n.year, n.month, n.day ) )
示例#9
0
 def test_returntype(self):
     self.assertSequenceType(bahai.from_gregorian(2020, 6, 4), int)