Skip to content

Commit ea85c7a

Browse files
committed
Replace deprecated datetime.utcfromtimestamp
It was deprecated in Python 3.12 in favor of datetime.fromtimestamp[1]. [1] https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp Change-Id: Ia805157eaecac0c61d4c5f88daa430ec6d69a9d4
1 parent f4c4a73 commit ea85c7a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

openstackclient/image/v2/cache.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@ def _format_image_cache(cached_images):
3737
image_obj = copy.deepcopy(image)
3838
image_obj['state'] = 'cached'
3939
image_obj['last_accessed'] = (
40-
datetime.datetime.utcfromtimestamp(
41-
image['last_accessed']
42-
).isoformat()
40+
datetime.datetime.fromtimestamp(
41+
image['last_accessed'], tz=datetime.timezone.utc
42+
)
43+
.replace(tzinfo=None)
44+
.isoformat()
4345
)
4446
image_obj['last_modified'] = (
45-
datetime.datetime.utcfromtimestamp(
46-
image['last_modified']
47-
).isoformat()
47+
datetime.datetime.fromtimestamp(
48+
image['last_modified'], tz=datetime.timezone.utc
49+
)
50+
.replace(tzinfo=None)
51+
.isoformat()
4852
)
4953
image_list.append(image_obj)
5054
elif item == "queued_images":

0 commit comments

Comments
 (0)