Skip to content

Commit 26d0b34

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 26d0b34

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/cmd-import

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ it into a `cosa build`, as if one did `cosa build ostree`. One can then e.g.
77
'''
88

99
import argparse
10-
import datetime
10+
from dateutil import (parser, tz)
1111
import json
1212
import os
1313
import subprocess
@@ -229,13 +229,8 @@ def skopeo_inspect(image):
229229

230230

231231
def parse_timestamp(timestamp):
232-
# datetime's doesn't support nanoseconds.
233-
# So trim it.
234-
if len(timestamp) > 26 and timestamp[19] == '.':
235-
timestamp = timestamp[:26] + "Z"
236-
237-
timestamp = datetime.datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
238-
return rfc3339_time(timestamp.replace(tzinfo=datetime.timezone.utc))
232+
timestamp = parser.parse(timestamp)
233+
return rfc3339_time(timestamp.astimezone(tz.UTC))
239234

240235

241236
if __name__ == '__main__':

0 commit comments

Comments
 (0)