calculate_time and calculate_discount

calculate_time is refactored,

and caculate_discount method was created based on the calculate_time code.