Add utc_now for deprecated datetime.datetime.utcnow

This commit is contained in:
2024-11-07 11:30:34 -06:00
parent 361fc13741
commit bc1a6f927f

View File

@@ -3,8 +3,10 @@ This module provides utility functions for database connection, string manipulat
"""
import os
from datetime import datetime
from typing import Optional
import pytz
from fastapi import Request
from peewee import PostgresqlDatabase
@@ -12,6 +14,13 @@ from peewee import PostgresqlDatabase
is_development = os.getenv("ENVIRONMENT") == "development"
def utc_now() -> datetime:
"""
A utility function to replace the deprecated datetime.datetime.utcnow() function.
"""
return datetime.now(pytz.utc)
def get_db() -> PostgresqlDatabase:
"""
Acquires the database connector from the BaseModel class.