Skip to content

Commit

Permalink
Resolve datetime deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Feb 8, 2024
1 parent 9447215 commit 2f2706a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions ixmp4/data/db/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import sqlite3
from datetime import datetime
from datetime import datetime, timezone
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -116,7 +116,10 @@ def get(self, *args, **kwargs) -> ModelType:

class Creator(BaseRepository[ModelType], abstract.Creator):
def get_creation_info(self) -> dict:
info = {"created_at": datetime.utcnow(), "created_by": "@unknown"}
info = {
"created_at": datetime.now(tz=timezone.utc),
"created_by": "@unknown",
}
if self.backend.auth_context is not None:
info["created_by"] = self.backend.auth_context.user.username
return info
Expand Down
4 changes: 2 additions & 2 deletions ixmp4/server/rest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from fastapi import Depends, FastAPI, Path, Request
from fastapi.encoders import jsonable_encoder
Expand Down Expand Up @@ -69,7 +69,7 @@ def root(
version=version,
is_managed=settings.managed,
manager_url=str(settings.manager_url),
utcnow=datetime.utcnow(),
utcnow=datetime.now(tz=timezone.utc),
)


Expand Down

0 comments on commit 2f2706a

Please sign in to comment.