<commit_before>class Reservation < ActiveRecord::Base
  belongs_to :time_slot, class_name: "TimeSlot", foreign_key: :time_id, primary_key: :id
  belongs_to :restaurant
  belongs_to :user

  validates :user, presence: true
  validates :restaurant, presence: true

  validate :time_is_not_past
  validate :date_is_within_max_advance
  validate :time_slot_is_within_restaurant_hours
  validate :head_count_is_within_limit

  def time_is_not_past
    time_now = Time.now()
    date = self.date
    time_then = date.to_time + self.time_slot.time.minutes
    if time_then < time_now
      errors[:Time] = "is unfortunately linear"
    end

  end

  def time_slot_is_within_restaurant_hours
    id = self.time_slot.id
    opens, closes = self.restaurant.open_time.id, self.restaurant.close_time.id
    if id < opens || id > closes
      errors[:restaurant] = "is not open"
    end
  end

  def date_is_within_max_advance
    advance = self.restaurant.max_advance
    max_date = Time.now + advance.days
    if self.date > max_date
      errors[:date] = "past the restaurant's maximum advance date"
    end
  end
<commit_msg>Try fix for heroku server time issue.<commit_after>class Reservation < ActiveRecord::Base
  belongs_to :time_slot, class_name: "TimeSlot", foreign_key: :time_id, primary_key: :id
  belongs_to :restaurant
  belongs_to :user

  validates :user, presence: true
  validates :restaurant, presence: true

  validate :time_is_not_past
  validate :date_is_within_max_advance
  validate :time_slot_is_within_restaurant_hours
  validate :head_count_is_within_limit

  def time_is_not_past
    time_now = Time.now()
    date = self.date
    time_then = date.to_time + self.time_slot.time.minutes
    if time_then < time_now.in_time_zone('Eastern Time (US & Canada)')
      errors[:Time] = "is unfortunately linear"
    end

  end

  def time_slot_is_within_restaurant_hours
    id = self.time_slot.id
    opens, closes = self.restaurant.open_time.id, self.restaurant.close_time.id
    if id < opens || id > closes
      errors[:restaurant] = "is not open"
    end
  end

  def date_is_within_max_advance
    advance = self.restaurant.max_advance
    max_date = Time.now + advance.days
    if self.date > max_date
      errors[:date] = "past the restaurant's maximum advance date"
    end
  end

{'fraction_non_alphanumeric': 0.07872988255763376, 'fraction_numerical': 0.0, 'mean_word_length': 3.8625792811839323, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7188080', 'n_tokens_mistral': 818, 'n_tokens_neox': 769, 'n_words': 183}