views:

24

answers:

1

I have some date objects that are Date of the Date class, and others that are Time.

The trouble is is that when I parse them to load them chronologically, they list first as the Times, followed by the Dates.

This is the code that loads them :

  query.any_of do |any_of|
    any_of.with(:date).greater_than((params[:current_date] || DateTime.now))
    any_of.with(:end_date).greater_than((params[:current_date] || DateTime.now))
    any_of.with(:time).greater_than((params[:current_date] || DateTime.now))
  end

Is there a way to combine both dates and times as one universal object to compare them? Ideally, it would be converting the Date Objects to Time since Time objects can hold dates and time.

A: 
def universal_time
  if self.date != nil
    self.date.to_time
  else
    self.time
  end
end
Trip