python - Increment times if date has changed? -
i have list of strings, , 1 of them looks this:
'thu jun 18 19:58:02 2015 ...many lines of data... txup: 19:59:47 txdown: 20:05:22 rxup: 21:43:17 rxdown: 22:13:01'
but may this:
'fri jun 19 23:12:12 2015 ...many lines of data... txup: 23:39:47 txdown: 23:57:22 rxup: 00:01:17 rxdown: 01:13:01'
as can see, in cases time might cross midnight. when happens, using above string example, date associated time jun 20 instead of jun 19.
i need write code compares 'rxup' time date/time @ start of string , recognizes if , when increases day because passed midnight (all relative date/time @ beginning).
if hasn't crossed midnight , same day, i'm done. if has crossed midnight, need take difference between time , time @ beginning timedelta object, , add increment onto copy of time @ beginning. how this?
if times grow monotonously can compare them in lexicographic order. '00:01:17' less '23:39:47', each time next timestamp less current one, increment date.
Comments
Post a Comment