本文整理匯總了Python中khayyam.JalaliDatetime.date方法的典型用法代碼示例。如果您正苦於以下問題:Python JalaliDatetime.date方法的具體用法?Python JalaliDatetime.date怎麽用?Python JalaliDatetime.date使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類khayyam.JalaliDatetime
的用法示例。
在下文中一共展示了JalaliDatetime.date方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_instantiate
# 需要導入模塊: from khayyam import JalaliDatetime [as 別名]
# 或者: from khayyam.JalaliDatetime import date [as 別名]
def test_instantiate(self):
jalali_time = JalaliDatetime(1376, 10, 9, 8, 7, 6, 5)
self.assertFalse(jalali_time is None)
self.assertEqual(JalaliDatetime(jalali_time.todatetime()), jalali_time)
self.assertEqual(JalaliDatetime(jalali_time), jalali_time)
self.assertEqual(JalaliDatetime(jalali_time.date()).date(), jalali_time.date())
self.assertEqual(JalaliDatetime(julian_day=2450674), JalaliDatetime(1376, 5, 23))
示例2: test_sub
# 需要導入模塊: from khayyam import JalaliDatetime [as 別名]
# 或者: from khayyam.JalaliDatetime import date [as 別名]
def test_sub(self):
jalali_time1 = JalaliDatetime(self.leap_year, 12, 23)
jalali_time2 = jalali_time1 - timedelta(10)
self.assertEqual(jalali_time2, JalaliDatetime(self.leap_year, 12, 13))
difference = jalali_time1 - JalaliDatetime(self.leap_year - 1, 12, 1)
self.assertEqual(difference, timedelta(387))
jalali_time1 = JalaliDatetime(self.leap_year, 12, 23, 4, 2, 10, 7)
self.assertEqual(jalali_time1 - jalali_time1.date(), timedelta(hours=4, minutes=2, seconds=10, microseconds=7))