fix: Update timezone to get wday from working_hours (#5605)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Tejaswini Chile
2022-10-13 03:02:54 +05:30
committed by GitHub
parent 1b5a335f93
commit fca629a32a
4 changed files with 20 additions and 1 deletions

View File

@@ -40,7 +40,10 @@ class WorkingHour < ApplicationRecord
validate :open_all_day_and_closed_all_day
def self.today
find_by(day_of_week: Date.current.wday)
# While getting the day of the week, consider the timezone as well. `first` would
# return the first working hour from the list of working hours available per week.
inbox = first.inbox
find_by(day_of_week: Time.zone.now.in_time_zone(inbox.timezone).to_date.wday)
end
def open_at?(time)