Skip to content

Commit 705bcb1

Browse files
committed
Fix for datetime format.
1 parent c69c9e5 commit 705bcb1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ async def update_item(
707707
"""
708708
item = item.model_dump(mode="json")
709709
base_url = str(kwargs["request"].base_url)
710-
now = datetime_type.now(timezone.utc).isoformat().replace("+00:00", "Z")
710+
now = datetime_type.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
711711
item["properties"]["updated"] = now
712712

713713
await self.database.check_collection_exists(collection_id)

stac_fastapi/tests/api/test_api.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ async def test_app_sort_extension_get_asc(app_client, txn_client, ctx):
254254
another_item_date = datetime.strptime(
255255
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
256256
) - timedelta(days=1)
257-
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
258-
"+00:00", "Z"
257+
second_item["properties"]["datetime"] = another_item_date.strftime(
258+
"%Y-%m-%dT%H:%M:%SZ"
259259
)
260260

261261
await create_item(txn_client, second_item)
@@ -276,9 +276,10 @@ async def test_app_sort_extension_get_desc(app_client, txn_client, ctx):
276276
another_item_date = datetime.strptime(
277277
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
278278
) - timedelta(days=1)
279-
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
280-
"+00:00", "Z"
279+
second_item["properties"]["datetime"] = another_item_date.strftime(
280+
"%Y-%m-%dT%H:%M:%SZ"
281281
)
282+
282283
await create_item(txn_client, second_item)
283284

284285
resp = await app_client.get("/search?sortby=-properties.datetime")
@@ -297,9 +298,10 @@ async def test_app_sort_extension_post_asc(app_client, txn_client, ctx):
297298
another_item_date = datetime.strptime(
298299
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
299300
) - timedelta(days=1)
300-
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
301-
"+00:00", "Z"
301+
second_item["properties"]["datetime"] = another_item_date.strftime(
302+
"%Y-%m-%dT%H:%M:%SZ"
302303
)
304+
303305
await create_item(txn_client, second_item)
304306

305307
params = {
@@ -322,8 +324,8 @@ async def test_app_sort_extension_post_desc(app_client, txn_client, ctx):
322324
another_item_date = datetime.strptime(
323325
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
324326
) - timedelta(days=1)
325-
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
326-
"+00:00", "Z"
327+
second_item["properties"]["datetime"] = another_item_date.strftime(
328+
"%Y-%m-%dT%H:%M:%SZ"
327329
)
328330
await create_item(txn_client, second_item)
329331

0 commit comments

Comments
 (0)