code: def generate(minimum, maximum, local_random=random.Random()):
      
      if not (minimum < maximum):
          raise ValueError('{} is not smaller than {}'.format(minimum, maximum))
  
      # Python 3 allows direct multiplication of timedelta with a float, but
      # Python 2.7 does not. Hence this work-around.
      time_d = maximum - minimum
      time_d_float = time_d.total_seconds()
      time_d_rand = dt.timedelta(seconds=time_d_float * local_random.random())
      generated = minimum + time_d_rand
      return generated
docs: Generate a random date.
  
      The generated dates are uniformly distributed.
  
      Parameters
      ----------
      minimum : datetime object
      maximum : datetime object
      local_random : random.Random
  
      Returns
      -------
      generated_date : datetime object
  
      Examples
      --------
      >>> import random; r = random.Random(); r.seed(0)
      >>> from datetime import datetime
  
      >>> generate(datetime(2018, 1, 1), datetime(2018, 1, 2), local_random=r)
      datetime.datetime(2018, 1, 1, 20, 15, 58, 47972)
  
      >>> generate(datetime(2018, 1, 1), datetime(2018, 1, 2), local_random=r)
      datetime.datetime(2018, 1, 1, 18, 11, 27, 260414)