import time


def end_time_measuring(start_time, what_to_measure='', print_end_time=True):
    """
    Returns the end time and duration of an operation.

    :param start_time: localtime. Start time of an operation.
    :param what_to_measure: string. What to measure. For print out.
    :param print_end_time: boolean. True for printing out the end time.
    :return: localtime, second. End time, duration.
    """
    endtime = time.localtime()
    if print_end_time:
        print('End time', what_to_measure, ':', time.strftime('%a, %d %b %Y %H:%M:%S', endtime))
    duration = int(time.mktime(endtime) - time.mktime(start_time))
    print(what_to_measure.capitalize(), 'took:', (duration // 3600), 'hours', (duration % 3600) // 60,
          'minutes', (duration % 3600) % 60, 'seconds')
    return endtime, duration