code: def to_time(time, granularity):
      
      if not granularity:
          if type(time) is datetime.date:
              return format_date(time)
          else:
              return format_time(time)
      if granularity == GRANULARITY.HOUR:
          return format_time(remove_minutes(time))
      elif granularity == GRANULARITY.DAY:
          return format_date(remove_hours(time))
      else:
          return format_time(time)
docs: Returns a truncated and rounded time string based on the specified granularity.