我有一个cron作业在Rails服务器上运行。当某些事件触发时,此rake任务向订阅者发出呼叫/SMS。现在,当这个事件在用户选择的免打扰时间之间触发时,我想将其存储在一个队列中。如何检查时间是否在用户选择的免打扰时间之间?
我尝试在Time between specified range中回答提及
但当用户选择免打扰时间为6到9时失败
Note:- 1] Every user has its own timezone.. Which I have in the database
2] Every user can select his/her own DND Time.发布于 2012-04-17 20:19:43
我认为在以下情况下将会起作用
start_hour = Hour when DND Time Starts
end_hour = Hour when DND Time Ends
current hour = Hour of the current time然后
if start_hour > end_hour
current hour > start_hour || current hour < end_hour
else
current hour > start_hour && current hour < end_hour
end或
start_hour > end_hour ? (current hour > start_hour || current hour < end_hour) :
(current hour > start_hour && current hour < end_hour)https://stackoverflow.com/questions/10190671
复制相似问题