def _to_datetime(self, element): if self.ref_date is None and '-' not in element: return parse_time(element) else: if '-' in element: date = self._ref_date_to_datetime(element.split('_')[0]) return parse_time("000_" + element.split('_')[1], date) return parse_time(element, self.ref_date)
def _to_datetime(self, element): if self.ref_date is None and '-' not in element: # Only hh:mm:ss case if len(element) == 8: elements = [int(e) for e in element.split(':')] return time(elements[0], elements[1], elements[2]) return parse_time(element) else: # Only hh:mm:ss case if len(element) == 8: return parse_time("000_" + element, self.ref_date) elif '-' in element: date = self._ref_date_to_datetime(element.split('_')[0]) return parse_time("000_" + element.split('_')[1], date) return parse_time(element, self.ref_date)