Sha256: 82a67dbfa70a0081283aa68f771d174e58c003b75c3157be5efac8c7353574ba
Contents?: true
Size: 906 Bytes
Versions: 1
Compression:
Stored size: 906 Bytes
Contents
# frozen_string_literal: true module Qismo class Util class << self def in_office_hour?(data) return false if data.timezone.blank? offset = Time.zone_offset(data.timezone) tz_current = Time.current.getlocal(offset) today_office_hour = data.office_hours.find { |oh| oh.day == tz_current.strftime("%u").to_i } return false if today_office_hour.nil? start_hour = today_office_hour.starttime end_hour = today_office_hour.endtime # rubocop:disable Layout/LineLength start_time = Time.parse("#{tz_current.year}-#{tz_current.month}-#{tz_current.day} #{start_hour} #{data.timezone}") end_time = Time.parse("#{tz_current.year}-#{tz_current.month}-#{tz_current.day} #{end_hour} #{data.timezone}") # rubocop:enable Layout/LineLength tz_current.between?(start_time, end_time) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
qismo-0.8.7 | lib/qismo/util.rb |