mirror of
https://github.com/Xevion/linkpulse.git
synced 2025-12-07 20:07:34 -06:00
Add utc_now for deprecated datetime.datetime.utcnow
This commit is contained in:
@@ -3,8 +3,10 @@ This module provides utility functions for database connection, string manipulat
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from datetime import datetime
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
import pytz
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
from peewee import PostgresqlDatabase
|
from peewee import PostgresqlDatabase
|
||||||
|
|
||||||
@@ -12,6 +14,13 @@ from peewee import PostgresqlDatabase
|
|||||||
is_development = os.getenv("ENVIRONMENT") == "development"
|
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:
|
def get_db() -> PostgresqlDatabase:
|
||||||
"""
|
"""
|
||||||
Acquires the database connector from the BaseModel class.
|
Acquires the database connector from the BaseModel class.
|
||||||
|
|||||||
Reference in New Issue
Block a user