Exemple #1
0
def calc_times():
  """
  Passes the values passed to it to 
  calc_duration_open and close  
  Expects the number of brevet_distance.
  Also Expects the current distance
  start_time and start date. 
  """
  app.logger.debug("Got a JSON request");
  cont = request.args.get('distance', 0, type=int)
  total_distance = request.args.get('total_dist', 0, type= int)
  start_time = request.args.get('start', 0, type = str)
  start_date = request.args.get('date', 0, type = str)
  
  final_date = start_date + " " + start_time
  
  ##set the date
  date = arrow.get(final_date, 'MM/DD/YYYY HH:mm')
  
  ##Calculate the date and time of distance
  open_time = calc_duration_open(cont, total_distance)
  close_time = calc_duration_close(cont, total_distance)
  
  #need to get date time to 0
  first_o = calc_duration_open(0, total_distance)
  first_c = calc_duration_close(0, total_distance)
  first_date_open = date.replace(hours=first_o[0], minutes=first_o[1]).format("MM/DD/YYYY HH:mm")
  first_date_close = date.replace(hours=first_c[0], minutes=first_c[1]).format("MM/DD/YYYY HH:mm")
  
  #now set the dates with updated times
  start_date_time = date.replace(hours=open_time[0], minutes=open_time[1])
  start_date_close = date.replace(hours=close_time[0], minutes=close_time[1])
  
  #now makestrings
  final_close = start_date_close.format("MM/DD/YYYY HH:mm")
  final_start = start_date_time.format("MM/DD/YYYY HH:mm")
  
  #pass it all back
  rslt = { "closeing": final_close, "start": final_start, 
                  "first_c": first_date_close, "first_o": first_date_open }
  return jsonify(result=rslt)
Exemple #2
0
def test_controls():

    assert calc_duration_close(0, 600) == [1, 0]
    assert calc_duration_close(0, 1000) == [1, 0]
    assert calc_duration_open(0, 200) == [0, 0]
    assert calc_duration_open(0, 600) == [0, 0]
Exemple #3
0
def test_endOfRide():

    assert calc_duration_close(600, 600) == calc_duration_close(603, 600)
    assert calc_duration_open(200, 200) == calc_duration_open(210, 200)