本文整理汇总了Python中delorean.Delorean.time方法的典型用法代码示例。如果您正苦于以下问题:Python Delorean.time方法的具体用法?Python Delorean.time怎么用?Python Delorean.time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类delorean.Delorean
的用法示例。
在下文中一共展示了Delorean.time方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_time_timtravel
# 需要导入模块: from delorean import Delorean [as 别名]
# 或者: from delorean.Delorean import time [as 别名]
def test_time_timtravel(self, seconds=1, minutes=1, microseconds=100):
d = Delorean()
sample = datetime(2011, 10, 10, 1, 33, 4, 121940)
d.utcdatetime = sample
current_time = d.datetime()
current_time = current_time + timedelta(seconds=1, minutes=1, microseconds=100)
d.timetravel(seconds=1, minutes=1, microseconds=100)
self.assertEqual(d.time(), current_time.time())
示例2:
# 需要导入模块: from delorean import Delorean [as 别名]
# 或者: from delorean.Delorean import time [as 别名]
# Check each day until we hit the day that is today, in the
# user's timezone.
for range in schedule.ranges:
if range.day is not None and range.day.name == day_names[day]:
# Print out today's users who have hours, as an aid.
print "%s\t%s\t%s" % (luser.profile[0].username,
range.start_time,
range.end_time)
# Only notify within the first 15 minutes of the hour after.
# This will allow us to use the flow of time to avoid
# duplicating notifications.
time_now = now.time()
end_time_in_minutes = range.end_time.hour * 60 + range.end_time.minute
now_in_minutes = time_now.hour * 60 + time_now.minute
# If it is within 15 minutes after an hour has passed,
# send the reminder email
if end_time_in_minutes + 60 < now_in_minutes and \
now_in_minutes < end_time_in_minutes + 75:
# send the email.
mailer.send(from_addr=MAIL_FROM, to_addr=luser.email,
subject="Reminder: Please report in on %s" % \
schedule.project.name,
text=message % \