% non_working_days = Setting.non_working_week_days || [] app_datetime = (appointment.respond_to?(:date) && appointment.date.present?) ? appointment.date : appointment.start_date start_date = app_datetime.to_date target_date = day.to_date duration = [appointment.duration.to_i, 1].max day_number = 0 if target_date >= start_date date_cursor = start_date working_count = 0 while date_cursor <= target_date unless non_working_days.include?(date_cursor.cwday.to_s) working_count += 1 end if date_cursor == target_date day_number = working_count break end date_cursor += 1 end end %> <% status = appointment.status_record css = ['appointment-block', 'tooltip', (appointment.call_out? ? 'call-out' : status.key.parameterize), ('no-hours' if status && !status.counts_hours?)] %> <%= tag.div class: css.compact, style: status&.style do %>