【发布时间】:2015-08-20 00:15:03
【问题描述】:
我正在使用 dateutils 来预测旅途中的到达时间。
我可以将开始时间表示为日期时间对象。太好了。
我可以将旅程时间表示为时间增量。也不错
问题:我不清楚我将如何表示会议时间以便适用于任何工作日?
注意事项: 如果我使用 datetime 对象,我将不得不声明特定日期的会议时间。这意味着我必须每天更新它。这是相当乏味的。我更喜欢允许我在 '09:00:00' 说出“任何 {MON,TUE,WED,THU,FRI,SAT,SUN} 天”的符号
伪例子
import datetime
import dateutils
# setting start time as datetime object.
start = '2015-08-19T08:00:00'
# going from home to work:
mondays = 3000 # seconds as timedelta.
arrival = start + journey_time # calculating arrival time.
# recording the first meeting...
meeting = '09:00:00' # <--------------How should I represent this value?
arrival < meeting: # <------------- The all important check.
# should return True, if I can make it.
【问题讨论】:
-
既然在每天的计算中需要更新起始值,为什么不更新到达时间呢?我想最终你会想要将它与某种日历同步?那么更新应该不是问题?
标签: python python-3.x python-dateutil