Business time是伟大的宝石,但我想知道我可以在多个工作时间使用它来获取多个记录,例如我有多个餐馆的记录,这些记录有不同的商业时间,如此
[
Mon: {
morning: {
from: 9:00 am, to: 12:00 pm
},
noon:{
from: 2:00 am, to: 5:00 pm
},
night{
from: 7:00pm to: 11:pm
}
},
Tue: {
morning: {
from: 10:00 am, to: 12:00 pm
},
noon:{
from: 1:00 am, to: 5:00 pm
},
night: {
from: 7:00pm to: 11:pm
}
},
Wed: {
morning: {
from: 9:30 am, to: 12:00 pm
},
noon:{
from: 1:30 am, to: 5:00 pm
},
night:{
from: 7:00pm to: 11:pm
}
},
Thu:{
morning: {
from: 9:00 am, to: 01:00 pm
},
noon:{
from: 1:00 am, to: 5:00 pm
},
night:
{
from: 7:00pm to: 11:pm
}
},
Fri:{
morning: {
from: 9:00 am, to: 01:00 pm
},
noon:{
from: 1:00 am, to: 5:00 pm
},
night:{
from: 7:00pm to: 11:pm
}
}
Sat: off
Sun: off
]
我可以使用这个gem来实现这个吗?如果是,那怎么样?还是有其他宝石可以帮我吗?
答案 0 :(得分:0)
那个宝石也允许这样做。如果有帮助,请参阅下文
three_day_weekend = Date.parse("July 5th, 2010")
BusinessTime::Config.holidays << three_day_weekend
friday_afternoon = Time.parse("July 2nd, 2010, 4:50 pm")
tuesday_morning = 1.business_hour.after(friday_afternoon)
BusinessTime::Config.work_week = [:sun, :mon, :tue, :wed, :thu]
thursday_afternoon = Time.parse("July 8th, 2010, 4:50 pm")
sunday_morning = 1.business_hour.after(thursday_afternoon)