<reponame>lizebang/think-python-2e-examples
class Time:
    """Represents the time of day.
    attributes: hour, minute, second
    """


# pure functions, modifiers and designed development
# think python 2e -- chapter16

# designed development


def time_to_int(time):
    minutes = time.hour * 60 + time.minute
    seconds = minutes * 60 + time.second
    return seconds


def int_to_time(seconds):
    time = Time()
    minutes, time.second = divmod(seconds, 60)
    time.hour, time.minute = divmod(minutes, 60)
    return time


def add_time(t1, t2):
    seconds = time_to_int(t1) + time_to_int(t2)
    return int_to_time(seconds)

class Time:
    """Represents the time of day.
    attributes: hour, minute, second
    """


# pure functions, modifiers and designed development
# think python 2e -- chapter16

# designed development


def time_to_int(time):
    minutes = time.hour * 60 + time.minute
    seconds = minutes * 60 + time.second
    return seconds


def int_to_time(seconds):
    time = Time()
    minutes, time.second = divmod(seconds, 60)
    time.hour, time.minute = divmod(minutes, 60)
    return time


def add_time(t1, t2):
    seconds = time_to_int(t1) + time_to_int(t2)
    return int_to_time(seconds)
Represents the time of day.     attributes: hour, minute, second # pure functions, modifiers and designed development # think python 2e -- chapter16 # designed development