in pyscripts/docker_log_processor.py [0:0]
def get_timestamp_delta(self, date_one, date_two, line_count=0, line_mod=100):
"""
Diff date_one and date_two then format string for readability.
Delta of the strings are converted by fields.
line_count can be used to print a full timestamp every line_mod (%) lines
"""
if line_mod != 0 and line_count % line_mod == 0:
return date_one
time_delta_str = ""
delimiters = (".", "-", " ", ":")
field_count = 0
all_fields_one = self.split(date_one, delimiters)
all_fields_two = self.split(date_two, delimiters)
for field1 in all_fields_one:
if field1 == all_fields_two[field_count]:
for _ in field1:
time_delta_str += " "
else:
time_delta_str += all_fields_one[field_count]
if field_count < 2:
time_delta_str += "-"
elif field_count == 2:
time_delta_str += " "
elif field_count > 2 and field_count < 5:
time_delta_str += ":"
elif field_count == 5:
time_delta_str += "."
field_count += 1
return time_delta_str