【发布时间】:2016-08-12 13:20:44
【问题描述】:
如果dte 在当前时间的 1 小时内,我的目标是停止循环。有没有“红宝石方式”来做到这一点?
#THIS IS AN INFINITE LOOP, DONT RUN THIS
dte=DateTime.strptime("2000-01-01 21:00:00", '%Y-%m-%d %H:%M:%S')
while(dte<(DateTime.now.to_time-1).to_datetime)
#increments dte by one hour, not shown here
end
【问题讨论】: