@@ -119,6 +119,28 @@ def get_frames(f, arr, axis0):
119119 created = attrs ["Date and Time" ] # is this UTC?
120120 created = time .strptime (created , "%a %b %d %H:%M:%S %Y" )
121121 created = timestamp .TimeStamp (time .mktime (created )).RFC3339
122+ except ValueError : #round fractional seconds assuming it is the culprit
123+ try :
124+ HMS = created .split (' ' )[3 ].split (':' )
125+ round_seconds = int (round (float (HMS [- 1 ])))
126+ HMS_rounded = HMS [0 ] + ':' + HMS [1 ] + ':' + str (round_seconds )
127+ created_rounded = []
128+ for i ,p in enumerate (created .split (' ' )):
129+ if i > 0 :
130+ created_rounded .append (' ' )
131+ if i != 3 :
132+ created_rounded .append (p )
133+ else :
134+ created_rounded .append (HMS_rounded )
135+ created = "" .join (created_rounded )
136+ created = time .strptime (created , "%a %b %d %H:%M:%S %Y" )
137+ created = timestamp .TimeStamp (time .mktime (created )).RFC3339
138+ except (ValueError , IndexError ) as e : #rounding failed, saving modified time instead:
139+ created = os .stat (filepath ).st_mtime
140+ created = timestamp .TimeStamp (created ).RFC3339
141+ warnings .warn (
142+ f"{ filepath .name } has a 'Date and Time' format that does not match %a %b %d %H:%M:%S %Y: using file modified time instead: { created } "
143+ )
122144 except KeyError : # use file creation time
123145 created = os .stat (filepath ).st_mtime
124146 created = timestamp .TimeStamp (created ).RFC3339
0 commit comments