Skip to content

Commit 3187279

Browse files
authored
Fix datetime method deprecation (#2182)
Fix datetime method deprecation
1 parent b8237be commit 3187279

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pygeoapi/api/itemtypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
from collections import ChainMap
3939
from copy import deepcopy
40-
from datetime import datetime
40+
from datetime import datetime, UTC
4141
from http import HTTPStatus
4242
import logging
4343
from typing import Any, Tuple, Union
@@ -625,7 +625,7 @@ def get_collection_items(
625625
'href': '/'.join(uri.split('/')[:-1])
626626
})
627627

628-
content['timeStamp'] = datetime.utcnow().strftime(
628+
content['timeStamp'] = datetime.now(UTC).strftime(
629629
'%Y-%m-%dT%H:%M:%S.%fZ')
630630

631631
# Set response language to requested provider locale

tests/load_tinydb_records.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# =================================================================
22
#
33
# Authors: Tom Kralidis <[email protected]>
4+
# Francesco Bartoli <[email protected]>
45
#
56
# Copyright (c) 2025 Tom Kralidis
7+
# Copyright (c) 2025 Francesco Bartoli
68
#
79
# Permission is hereby granted, free of charge, to any person
810
# obtaining a copy of this software and associated documentation
@@ -27,7 +29,7 @@
2729
#
2830
# =================================================================
2931

30-
from datetime import datetime
32+
from datetime import datetime, UTC
3133
from pathlib import Path
3234
import sys
3335
from typing import Union
@@ -226,7 +228,7 @@ def get_anytext(bag: Union[list, str]) -> str:
226228
'geometry': geometry,
227229
'properties': {
228230
'created': issued,
229-
'updated': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'),
231+
'updated': datetime.now(UTC).strftime('%Y-%m-%dT%H:%M:%SZ'),
230232
'type': type_,
231233
'title': title,
232234
'description': description,

0 commit comments

Comments
 (0)