def convert_work_times(project, day_string, time_strings):
    u"""
    Convert the arguments to work times.

    If this method could not convert, raise InvalidArgumentFormatException.

    Parameters:
        project : Name of the project.
        day_string : String of the day.
        time_strings : List of string of the times.
    Return:
        A list of work time dictionary.
    """
    # Time are pairs of start and end.
    # Therefore, the number of times should be an even number.
    if len(time_strings) % 2:
        raise work_recorder.InvalidArgumentFormatException()

    day = work_recorder.convert_day(day_string)

    times = [work_recorder.convert_time(a_time_string)
            for a_time_string in time_strings]

    # Input times should be sorted.
    if times != sorted(times):
        raise work_recorder.InvalidArgumentFormatException()

    start_times = []
    end_times = []
    time_count = 0
    for a_time in times:
        if time_count % 2:
            end_times.append(a_time)
        else:
            start_times.append(a_time)
        time_count += 1

    work_times = []
    for index in range(len(start_times)):
        a_work_time = {}
        a_work_time[WORK_TIME_KEY_PROJECT] = project
        a_work_time[WORK_TIME_KEY_DAY] = day
        a_work_time[WORK_TIME_KEY_START] = start_times[index]
        a_work_time[WORK_TIME_KEY_END] = end_times[index]
        work_times.append(a_work_time)

    return work_times
 def check_invalid(self, time_string):
     try:
         time = work_recorder.convert_time(time_string)
         self.fail(time)
     except work_recorder.InvalidArgumentFormatException:
         pass
 def test_format_hmm(self):
     self.assertEquals(u'05:35:00', work_recorder.convert_time(u'535'))