Skip to content

Commit a7a38ee

Browse files
PeaceRebeljlebon
authored andcommitted
cmd-import: Ignore microseconds in 'created' timestamp label
Not all images includes the timestamp with microseconds. Fixes: #4308
1 parent 8932119 commit a7a38ee

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
@@ -233,13 +233,8 @@ def skopeo_inspect(image):
233233

234234

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

244239

245240
if __name__ == '__main__':

0 commit comments

Comments
 (0)