From 1014e2226ccd81cb44b084d0012836365b71346e Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 6 Jun 2018 15:53:45 +0630 Subject: [PATCH] update valid time menu --- app/models/menu_category.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 218bacb8..63bdf6ef 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -57,9 +57,15 @@ class MenuCategory < ApplicationRecord to = 24 to = to * 3600 + to_t.min* 60 + to_t.sec else - h += 24 to = h*3600 + to_t.min* 60 + to_t.sec + c = current_t.hour + if c < 12 + + c +=24 + current = c*3600 + current_t.min* 60 + current_t.sec + + end end else # (after) noon if h > 12 @@ -72,6 +78,7 @@ class MenuCategory < ApplicationRecord day = Date.today.wday dayresult = menu.valid_days.include?(day.to_s) + if current.between?(from, to) && menu.valid_days.include?(day.to_s) return true else @@ -108,3 +115,7 @@ class MenuCategory < ApplicationRecord end end + + + +