本文整理汇总了Python中app.models.Event.human_readable_time方法的典型用法代码示例。如果您正苦于以下问题:Python Event.human_readable_time方法的具体用法?Python Event.human_readable_time怎么用?Python Event.human_readable_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.Event
的用法示例。
在下文中一共展示了Event.human_readable_time方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_human_readable_time
# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import human_readable_time [as 别名]
def test_human_readable_time(self):
"""Test that :func:`~app.models.Event.human_readable_time` properly
formats event times into human readable time strings.
"""
from app.models import Event
any_date = date(2015, 03, 31)
for start_time, end_time, string in self.TIMES:
event = Event(start_date=any_date,
start_time=start_time,
end_date=any_date,
end_time=end_time,
**self.EVENT_KWARGS)
msg = self.ERROR_MSG.format('human readable time',
string,
event.human_readable_time())
self.assertEqual(event.human_readable_time(), string, msg=msg)
示例2: test_event_starting_on_midnight
# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import human_readable_time [as 别名]
def test_event_starting_on_midnight(self):
"""Test that events starting on midnight are properly formatted."""
from app.models import Event
start_date, start_time = date(2015, 04, 01), time(00)
end_date, end_time = date(2015, 04, 01), time(05, 30)
event = Event(start_date=start_date,
start_time=start_time,
end_date=end_date,
end_time=end_time,
**self.EVENT_KWARGS)
self.assertFalse(event.is_multiday())
self.assertEqual(event.human_readable_date(), 'Wednesday, April 1')
self.assertEqual(event.human_readable_time(), '12-5:30am')
示例3: test_event_ending_on_midnight
# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import human_readable_time [as 别名]
def test_event_ending_on_midnight(self):
"""Test that events ending on midnight are properly formatted."""
from app.models import Event
start_date, start_time = date(2015, 03, 31), time(22)
end_date, end_time = date(2015, 04, 01), time(0)
event = Event(start_date=start_date,
start_time=start_time,
end_date=end_date,
end_time=end_time,
**self.EVENT_KWARGS)
self.assertFalse(event.is_multiday())
self.assertEqual(event.human_readable_date(), 'Tuesday, March 31')
self.assertEqual(event.human_readable_time(), '10pm-12am')