diff --git a/app/controllers/destination_form_controller.rb b/app/controllers/destination_form_controller.rb index 68387aa..d7e8ec0 100644 --- a/app/controllers/destination_form_controller.rb +++ b/app/controllers/destination_form_controller.rb @@ -22,6 +22,14 @@ def create kk_res = [] # 経由地間のjson sk_keisan =[] # 出発地から経由地の途中計算 + + if @hour == "-1" && @minute == "-1" + d = DateTime.now + @hour = d.hour + @minute = d.minute + end + + # スタートからそれぞれの経由地の時間を取得する [@destination_1, @destination_2].each do |d| uri = URI.encode('https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins='+@origin+'&destinations='+d+'&mode=driving&key='+ENV['API_KEY']) @@ -222,8 +230,8 @@ def create if @gokei_sd2_h >= 24 @gokei_sd2_h = @gokei_sd2_h.to_i - 24 end - @gokei_sd2d1_h = @sd2d1hour + @hour.to_i - @gokei_sd2d1_m = @sd2d1minute + @minute.to_i + @gokei_sd2d1_h = @sd2d1hour.to_i + @hour.to_i + @gokei_sd2d1_m = @sd2d1minute.to_i + @minute.to_i if @gokei_sd2d1_m >= 60 @gokei_sd2d1_h += 1 @gokei_sd2d1_m -= 60 diff --git a/app/views/destination_form/create.html.erb b/app/views/destination_form/create.html.erb index 8b415e6..062bba9 100644 --- a/app/views/destination_form/create.html.erb +++ b/app/views/destination_form/create.html.erb @@ -14,11 +14,14 @@ <%= @skk_h %>:<%= @skk_m %> <%= @near2 %> <% else %> - <%= @gokei_sd2_h %>:<%= @gokei_sd2_m %> <%= @near2 %> + + <% @near1,@near2 = @near2, @near1%> + + <%= @gokei_sd2_h %>:<%= @gokei_sd2_m %> <%= @near1 %> ↓ - <%= @gokei_sd2d1_h %>:<%= @gokei_sd2d1_m %> <%= @near1 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>) + <%= @gokei_sd2d1_h %>:<%= @gokei_sd2d1_m %> <%= @near2 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>) <% end %> <% elsif @destination_1 == @near2 %> <% if @orderz <= @reversez %> @@ -28,11 +31,14 @@ <%= @skk_h %>:<%= @skk_m %> <%= @near2 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>) <% else %> - <%= @gokei_sd1_h %>:<%= @gokei_sd1_m %> <%= @near2 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>) + + <% @near1,@near2 = @near2, @near1%> + + <%= @gokei_sd1_h %>:<%= @gokei_sd1_m %> <%= @near1 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>) ↓ - <%= @gokei_sd1d2_h %>:<%= @gokei_sd1d2_m %> <%= @near1 %> + <%= @gokei_sd1d2_h %>:<%= @gokei_sd1d2_m %> <%= @near2 %> <% end %> <% end %> diff --git a/app/views/destination_form/new.html.erb b/app/views/destination_form/new.html.erb index ec831fe..4969eea 100644 --- a/app/views/destination_form/new.html.erb +++ b/app/views/destination_form/new.html.erb @@ -13,15 +13,19 @@