當前位置: 首頁>>代碼示例>>Python>>正文


Python JalaliDate.todate方法代碼示例

本文整理匯總了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
開發者ID:pylover,項目名稱:khayyam,代碼行數:15,代碼來源:test_jalali_date.py

示例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)
開發者ID:pylover,項目名稱:khayyam,代碼行數:15,代碼來源:test_jalali_date.py

示例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())
開發者ID:pylover,項目名稱:khayyam,代碼行數:17,代碼來源:test_jalali_date.py

示例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)
開發者ID:siminbar,項目名稱:khayyam,代碼行數:6,代碼來源:test_jalali_date.py


注:本文中的khayyam.JalaliDate.todate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。