From 1659b5dbab167434662e2dcfc695501298f6d396 Mon Sep 17 00:00:00 2001 From: Francesco Bartoli Date: Thu, 11 Dec 2025 17:59:05 +0100 Subject: [PATCH] Fix datetime method deprecation FFix datetime method deprecation --- pygeoapi/api/itemtypes.py | 4 ++-- tests/load_tinydb_records.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pygeoapi/api/itemtypes.py b/pygeoapi/api/itemtypes.py index a1e1bda16..fae5f15d7 100644 --- a/pygeoapi/api/itemtypes.py +++ b/pygeoapi/api/itemtypes.py @@ -37,7 +37,7 @@ from collections import ChainMap from copy import deepcopy -from datetime import datetime +from datetime import datetime, UTC from http import HTTPStatus import logging from typing import Any, Tuple, Union @@ -625,7 +625,7 @@ def get_collection_items( 'href': '/'.join(uri.split('/')[:-1]) }) - content['timeStamp'] = datetime.utcnow().strftime( + content['timeStamp'] = datetime.now(UTC).strftime( '%Y-%m-%dT%H:%M:%S.%fZ') # Set response language to requested provider locale diff --git a/tests/load_tinydb_records.py b/tests/load_tinydb_records.py index 4c01fedf1..3afaf579c 100644 --- a/tests/load_tinydb_records.py +++ b/tests/load_tinydb_records.py @@ -1,8 +1,10 @@ # ================================================================= # # Authors: Tom Kralidis +# Francesco Bartoli # # Copyright (c) 2025 Tom Kralidis +# Copyright (c) 2025 Francesco Bartoli # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -27,7 +29,7 @@ # # ================================================================= -from datetime import datetime +from datetime import datetime, UTC from pathlib import Path import sys from typing import Union @@ -226,7 +228,7 @@ def get_anytext(bag: Union[list, str]) -> str: 'geometry': geometry, 'properties': { 'created': issued, - 'updated': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'), + 'updated': datetime.now(UTC).strftime('%Y-%m-%dT%H:%M:%SZ'), 'type': type_, 'title': title, 'description': description,