Skip to content

Commit ff89ae0

Browse files
committed
cmd-import: Ignore microseconds in 'created' timestamp label
Not all images includes the timestamp with microseconds. Fixes: #4308
1 parent 4ec5990 commit ff89ae0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/cmd-import

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,11 @@ def skopeo_inspect(image):
231231
def parse_timestamp(timestamp):
232232
# datetime's doesn't support nanoseconds.
233233
# So trim it.
234-
if len(timestamp) > 26 and timestamp[19] == '.':
235-
timestamp = timestamp[:26] + "Z"
234+
# ignore the microseconds too, as not all images has it.
235+
if len(timestamp) > 19:
236+
timestamp = timestamp[:19] + "Z"
236237

237-
timestamp = datetime.datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
238+
timestamp = datetime.datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%SZ')
238239
return rfc3339_time(timestamp.replace(tzinfo=datetime.timezone.utc))
239240

240241

0 commit comments

Comments
 (0)