Skip to content

Commit

Permalink
fix for time parsing (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonfb authored Oct 11, 2024
1 parent 285affc commit 0f30d15
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions app/helpers/hot_glue/controller_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def date_to_current_timezone(date, timezone = nil)

def modify_date_inputs_on_params(modified_params, current_user_object = nil, field_list = nil)
use_offset = (current_user_object.try(:timezone)) || server_timezone_offset

modified_params = modified_params.tap do |params|
params.keys.each{|k|

Expand All @@ -81,18 +80,14 @@ def modify_date_inputs_on_params(modified_params, current_user_object = nil, fie
end
if include_me
if use_offset != 0
puts "changing #{params[k]}"
zone = DateTime.now.in_time_zone(use_offset).zone

if use_offset.is_a? String
puts "parsing #{use_offset}"
zone = DateTime.now.in_time_zone(use_offset).zone
params[k] = DateTime.parse(params[k].gsub("T", " ") + " #{zone}")
else
puts "parsing #{use_offset}"
params[k] = DateTime.strptime("#{params[k]} #{use_offset}", '%Y-%m-%dT%H:%M %z').new_offset(0)
parse_date = "#{params[k].gsub("T", " ")} #{zone}"
params[k] = Time.strptime(parse_date, "%Y-%m-%d %H:%M:%S %Z")
end
puts "changed #{params[k]}"

end
end
}
Expand Down

0 comments on commit 0f30d15

Please sign in to comment.