本文整理汇总了Python中ics.event.Event.duration方法的典型用法代码示例。如果您正苦于以下问题:Python Event.duration方法的具体用法?Python Event.duration怎么用?Python Event.duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ics.event.Event
的用法示例。
在下文中一共展示了Event.duration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_duration
# 需要导入模块: from ics.event import Event [as 别名]
# 或者: from ics.event.Event import duration [as 别名]
def test_duration(self):
e = Event()
self.assertIsNone(e.duration)
e1 = Event(begin="1993/05/24")
e1.make_all_day()
self.assertEqual(e1.duration, timedelta(days=1))
e2 = Event(begin="1993/05/24", end="1993/05/30")
self.assertEqual(e2.duration, timedelta(days=6))
e3 = Event(begin="1993/05/24", duration=timedelta(minutes=1))
self.assertEqual(e3.duration, timedelta(minutes=1))
e4 = Event(begin="1993/05/24")
self.assertEqual(e4.duration, timedelta(seconds=1))
e5 = Event(begin="1993/05/24")
e5.duration = {'days': 6, 'hours': 2}
self.assertEqual(e5.end, arrow.get("1993/05/30T02:00"))
self.assertEqual(e5.duration, timedelta(hours=146))
示例2: test_duration
# 需要导入模块: from ics.event import Event [as 别名]
# 或者: from ics.event.Event import duration [as 别名]
def test_duration(self):
e = Event()
self.assertIsNone(e.duration)
birthday = Event(begin="1993/05/24")
self.assertEqual(birthday.duration, timedelta(days=1))
vacation = Event(begin="1993/05/24", end="1993/05/30")
self.assertEqual(vacation.duration, timedelta(days=7))
e3 = Event(begin=datetime(1993, 5, 24, 12),
duration=timedelta(minutes=1))
self.assertEqual(e3.duration, timedelta(minutes=1))
e4 = Event(begin=datetime(1993, 5, 24, 12))
self.assertEqual(e4.duration, timedelta(seconds=1))
e5 = Event(begin=datetime(1993, 5, 24, 12))
e5.duration = {'days': 6, 'hours': 2}
self.assertEqual(e5.end, parse_date_or_datetime("1993/05/30T14:00"))
self.assertEqual(e5.duration, timedelta(hours=146))