Skip to content
Browse files

fix for problems with date parsing

  • Loading branch information...
1 parent 6ffc7b4 commit ee27266ebb015f22473929b6478469ef7dd9d50f @jlapier committed Feb 27, 2012
View
7 app/controllers/event_calendar/events_controller.rb
@@ -43,10 +43,13 @@ def parse_dates_from_params
end_hour = params[:event].delete :"end_time(4i)"
end_min = params[:event].delete :"end_time(5i)"
if params[:event][:start_date].present?
- start_date = Date.parse(params[:event][:start_date])
+ # date is in format: MM/DD/YYYY
+ m, d, y = params[:event][:start_date].split("/").map(&:to_i)
+ start_date = Date.new y, m, d
params[:event][:start_on] = Time.utc(start_date.year, start_date.month, start_date.day, start_hour, start_min)
if params[:event][:end_date].present?
- end_date = Date.parse(params[:event][:end_date])
+ m, d, y = params[:event][:end_date].split("/").map(&:to_i)
+ end_date = Date.new y, m, d
else
end_date = start_date
end
View
8 spec/controllers/event_calendar/events_controller_spec.rb
@@ -111,8 +111,8 @@
let :params do
{
:event => {
- :start_date => Date.yesterday.to_s,
- :end_date => Date.tomorrow.to_s
+ :start_date => Date.yesterday.strftime("%m/%d/%Y"),
+ :end_date => Date.tomorrow.strftime("%m/%d/%Y")
}
}
end
@@ -158,8 +158,8 @@
{
:id => "37",
:event => {
- :start_date => Date.yesterday.to_s,
- :end_date => Date.tomorrow.to_s
+ :start_date => Date.yesterday.strftime("%m/%d/%Y"),
+ :end_date => Date.tomorrow.strftime("%m/%d/%Y")
}
}
end

0 comments on commit ee27266

Please sign in to comment.
Something went wrong with that request. Please try again.