本文整理汇总了Python中khayyam.JalaliDate.todate方法的典型用法代码示例。如果您正苦于以下问题:Python JalaliDate.todate方法的具体用法?Python JalaliDate.todate怎么用?Python JalaliDate.todate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类khayyam.JalaliDate
的用法示例。
在下文中一共展示了JalaliDate.todate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_algorithm
# 需要导入模块: from khayyam import JalaliDate [as 别名]
# 或者: from khayyam.JalaliDate import todate [as 别名]
def test_algorithm(self):
min = date(623, 1, 1)
max_days = 5000
days = 0
while True:
dt = min + timedelta(days=days)
jd = JalaliDate(dt)
# print('Processing day: %s' % jd)
dt2 = jd.todate()
self.assertEqual(dt, dt2)
days += 1
if days > max_days:
break
示例2: test_instantiate
# 需要导入模块: from khayyam import JalaliDate [as 别名]
# 或者: from khayyam.JalaliDate import todate [as 别名]
def test_instantiate(self):
jdate = JalaliDate(1376, 5, 23)
self.assertFalse(jdate is None)
self.assertEqual(JalaliDate(jdate.todate()), jdate)
self.assertEqual(JalaliDate(jdate), jdate)
self.assertEqual(JalaliDate(julian_day=2450674), jdate)
self.assertRaises(ValueError, JalaliDate, MAXYEAR + 1, 5, 23)
self.assertRaises(ValueError, JalaliDate, MAXYEAR, 13, 23)
self.assertRaises(ValueError, JalaliDate, MAXYEAR, 12, 30)
示例3: test_operators
# 需要导入模块: from khayyam import JalaliDate [as 别名]
# 或者: from khayyam.JalaliDate import todate [as 别名]
def test_operators(self):
invalid_object = dict(a=2)
d1 = JalaliDate(1361, 6, 15)
d2 = JalaliDate(1361, 6, 16)
self.assertRaises(TypeError, d1.__add__, invalid_object)
self.assertRaises(TypeError, d1.__sub__, invalid_object)
self.assertRaises(TypeError, d1.__lt__, invalid_object)
self.assertRaises(TypeError, d1.__gt__, invalid_object)
self.assertRaises(TypeError, d1.__eq__, invalid_object)
self.assertFalse(d1 == 0)
self.assertTrue(d1 == d1.todate())
self.assertTrue(d1 < d2)
self.assertTrue(d1 <= d1.copy())
self.assertFalse(d1 > d2)
self.assertTrue(d1 >= d1.copy())
示例4: test_to_from_date
# 需要导入模块: from khayyam import JalaliDate [as 别名]
# 或者: from khayyam.JalaliDate import todate [as 别名]
def test_to_from_date(self):
jdate = JalaliDate(self.leap_year, 12, 23)
jdate2 = JalaliDate.from_date(jdate.todate())
self.assertEqual(jdate, jdate2)