class Time
  def to_date
    Date.new(year, month, day)
  rescue NameError
    nil
  end
  def to_datetime
    DateTime.new(year, month, day, hour, min, sec)
  rescue NameError
    nil
  end
end

class DateTime
  def to_time
    Time.local(year,month,day,hour,min,sec)
  end
end

class Date
  def to_time
    Time.local(year,month,day)
  end
end

