diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 137e272ef..7f5537ce0 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -1,3 +1,4 @@ +require 'time_calculation' class Ticket < ApplicationModel before_create :number_generate, :check_defaults before_update :check_defaults diff --git a/lib/business_time/core_ext/time_fix.rb b/lib/business_time/core_ext/time_fix.rb index 9c03d6d07..956c73d08 100644 --- a/lib/business_time/core_ext/time_fix.rb +++ b/lib/business_time/core_ext/time_fix.rb @@ -54,7 +54,6 @@ class Time end while !Time.workday?(next_business_time) - puts '4' next_business_time += 1.day end @@ -94,7 +93,7 @@ class Time result += time_b - Time.parse(time_b.strftime('%Y-%m-%d ') + BusinessTime::Config.beginning_of_workday) # Last day # All days in between -puts "--- #{time_a}-#{time_b} - #{direction}" +#puts "--- #{time_a}-#{time_b} - #{direction}" # duration_of_working_day = Time.parse(BusinessTime::Config.end_of_workday) - Time.parse(BusinessTime::Config.beginning_of_workday) # result += (time_a.to_date.business_days_until(time_b.to_date) - 1) * duration_of_working_day @@ -107,7 +106,7 @@ puts "--- #{time_a}-#{time_b} - #{direction}" end_of_workday = Time.end_of_workday(time_c) if !Time.workday?(time_c) time_c = Time.beginning_of_workday(time_c) + 1.day - puts 'VACATIONS! ' + time_c.to_s +# puts 'VACATIONS! ' + time_c.to_s end if time_c.to_date == time_b.to_date if end_of_workday < time_b diff --git a/lib/time_calculation.rb b/lib/time_calculation.rb index 18b00ad72..e7714e380 100644 --- a/lib/time_calculation.rb +++ b/lib/time_calculation.rb @@ -32,7 +32,11 @@ module TimeCalculation end def self.dest_time(start_time, diff_in_min) - start_time = Time.parse( start_time.to_s + 'UTC' ) + start_time_string = start_time.to_s + if start_time.to_s != /UTC/ + start_time_string += ' UTC' + end + start_time = Time.parse( start_time_string ) dest_time = diff_in_min.round.business_minute.after( start_time ) return dest_time end