def add_time_units(time, unit, amount):
 args = {}
 if (unit == 'hour'):
  args['hours'] = amount
 elif (unit == 'day'):
  args['days'] = amount
 elif (unit == 'week'):
  args['days'] = (amount * 7)
 elif (unit == 'month'):
  args['months'] = amount
 elif (unit == 'quarter'):
  args['months'] = (amount * 3)
 elif (unit == 'year'):
  args['years'] = amount
 else:
  raise ArgumentError('Unknown unit %s for subtraction.')
 return (time + relativedelta(**args))

def add_time_units ( time , unit , amount ) : args = { } if ( unit == 'hour' ) : args [ 'hours' ] = amount elif ( unit == 'day' ) : args [ 'days' ] = amount elif ( unit == 'week' ) : args [ 'days' ] = ( amount * 7 ) elif ( unit == 'month' ) : args [ 'months' ] = amount elif ( unit == 'quarter' ) : args [ 'months' ] = ( amount * 3 ) elif ( unit == 'year' ) : args [ 'years' ] = amount else : raise ArgumentError ( 'Unknown unit %s for subtraction.' ) return ( time + relativedelta ( ** args ) )
subtract amount number of units from datetime object time .