Skip to content

Commit

Permalink
bug: double subseconds added
Browse files Browse the repository at this point in the history
  • Loading branch information
jernejaMislej committed Sep 17, 2018
1 parent 03d127c commit de3fbf2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions mapillary_tools/exif_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ def format_time(time_string):
e.g. 2014_03_31_24_10_11 => 2014_04_01_00_10_11
'''
subseconds = False
data = time_string.split("_")
hours, minutes, seconds = int(data[3]), int(data[4]), int(data[5])
date = datetime.datetime.strptime("_".join(data[:3]), "%Y_%m_%d")
subsec = 0
subsec = 0.0
if len(data) == 7:
subsec = float(data[6]) / 10**len(data[6])
if float(data[6]) != 0:
subsec = float(data[6]) / 10**len(data[6])
subseconds = True
date_time = date + \
datetime.timedelta(hours=hours, minutes=minutes,
seconds=seconds + subsec)
return date_time
return date_time, subseconds


def gps_to_decimal(values, reference):
Expand Down Expand Up @@ -165,8 +168,10 @@ def extract_capture_time(self):
capture_time = capture_time.replace("-", "_")
capture_time = "_".join(
[ts for ts in capture_time.split("_") if ts.isdigit()])
capture_time = format_time(capture_time)
sub_sec = self.extract_subsec()
capture_time, subseconds = format_time(capture_time)
sub_sec = "0"
if not subseconds:
sub_sec = self.extract_subsec()
capture_time = capture_time + \
datetime.timedelta(seconds=float("0." + sub_sec))

Expand Down

0 comments on commit de3fbf2

Please sign in to comment.