我想做的事情:
getOpenStatus = (restaurant: _Restaurant) => {
const closeHour = moment(restaurant.close_at, "HH:mm A").hours();
const closeMin = moment(restaurant.close_at, "HH:mm A").minutes();
const openHour = moment(restaurant.open_at, "HH:mm A").hours();
const openMin = moment(restaurant.open_at, "HH:mm A").minutes();
const closeMoment = moment({ hours: closeHour, minutes: closeMin });
const openMoment = moment({ hours: openHour, minutes: openMin });
return moment().isAfter(openMoment) && moment().isBefore(closeMoment);
}
假设当前时间是下午4:00
上午10:30开放,下午11:30关闭
在这种情况下可以完美地工作,因为时间在同一日期。
但是如果餐厅开放23小时该怎么办?
上午10:30开放,上午9:30关闭
那如何处理呢?
答案 0 :(得分:-1)
function isAdmin(request, uid) {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.admin == true
}
match /YOUR_COLLECTION/{doc} {
allow read: if isAdmin(request)
}