21 lines
558 B
Ruby
Raw Normal View History

2015-09-26 20:05:55 -07:00
class Event < ActiveRecord::Base
translates :info, :title
belongs_to :conference
belongs_to :event_location
2015-09-26 20:05:55 -07:00
def conference_day
return nil unless start_time.present? && end_time.present?
2015-09-26 20:05:55 -07:00
start_day = conference.start_date.change(hour: 0, minute: 0, second: 0)
w_start_day = start_time.change(hour: 0, minute: 0, second: 0)
return (((w_start_day - start_day) / 86400) + 1).to_i
end
2015-09-26 20:05:55 -07:00
def duration
return nil unless start_time.present? && end_time.present?
((end_time - start_time) / 60).to_i
end
2015-09-26 20:05:55 -07:00
end