This program is trying to merge history which has only a timestamp.
Assumption:
- The history data are continuous.
- The latest data is just before current time.
- The timestamp is the starting time of the record.
Sample data:
1 | history_list = [{"start_time": "0920", "result": 1}, |
Sample Output:
1 | Time: 0920-0940, Result: 1 |
Function to Merge history with same result:
1 | def merge_history_with_same_result(history_list): |
Function to calculating the duration:
1 | def cal_end_time(history_list, now): |
Main program
1 | history_list = merge_history_with_same_result(history_list) |