检查时间在9.30到4个ruby之间
发布时间:2020-12-16 22:33:27 所属栏目:百科 来源:网络整理
导读:我有一个代码错误地生成它,我认为必须有一个更好的方式来检查时间上午9时30分,时间 4 pm 任何想法都高度赞赏. def checkTime goodtime=false if(Time.now.hour9 and Time.now.min30) then if(Time.now.hour16) then goodtime=true else # do nothing end els
我有一个代码错误地生成它,我认为必须有一个更好的方式来检查时间>上午9时30分,时间< 4 pm
任何想法都高度赞赏. def checkTime goodtime=false if(Time.now.hour>9 and Time.now.min>30) then if(Time.now.hour<16) then goodtime=true else # do nothing end elsif Time.now.hour>9 and Time.now.hour<16 then goodtime=true else # do nothing end return goodtime end 解决方法t = Time.now Range.new( Time.local(t.year,t.month,t.day,9),Time.local(t.year,16,30) ) === t (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |