Topic: EVENT TIMES

I am trying to build a event calendar and i have a 4 fields
Start Time
End Time
Start Date
End Date

Where some one can say that the

Start Time | End Time | Start Date    | End Date
9 am         |   9 pm     | 10/01/2012 | 10/31/2012
9 pm         |  9 am      | 10/01/2012 | 10/31/2012

on my model i have a search that checks that now is between those time and it looks like

model

def self.search(account_id,datetime)
    if account_id
      where('account_id = ? ', "#{account_id}")
      .where('(start_date <= ? AND end_date >= ?)', "%#{datetime}%", "%#{datetime}%")
    end
  end

controller

event ||= Event.search(get_account.last.id,Time.now.in_time_zone("UTC") )

but the problem is that i dont know if the end time is before or after the start time

Last edited by moiseszaragoza (2012-10-01 17:01:15)