✅ Cambios Implementados:
1. PostgreSQL (Base de Datos) Variables de entorno: TZ=Atlantic/Canary y PGTZ=Atlantic/Canary Configurado en todos los archivos Docker: docker-compose.yml, docker-compose.prod.yml, docker-stack.yml 2. Backend (FastAPI/Python) Configuración de zona horaria al inicio de main.py Conexión a PostgreSQL con parámetro de timezone Event listener que establece timezone en cada conexión a la BD Variable de entorno: TZ=Atlantic/Canary 3. Frontend (React) Ya estaba usando fechas locales correctamente con el constructor new Date(year, month, day) 4. Migración SQL Creado set_timezone_canary.sql para actualizar la BD existente
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy import create_engine, event
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from app.core.config import settings
|
||||
@@ -6,9 +6,17 @@ from app.core.config import settings
|
||||
engine = create_engine(
|
||||
settings.DATABASE_URL,
|
||||
pool_pre_ping=True,
|
||||
echo=settings.ENVIRONMENT == "development"
|
||||
echo=settings.ENVIRONMENT == "development",
|
||||
connect_args={"options": "-c timezone=Atlantic/Canary"}
|
||||
)
|
||||
|
||||
# Configurar zona horaria al conectar
|
||||
@event.listens_for(engine, "connect")
|
||||
def set_timezone(dbapi_conn, connection_record):
|
||||
cursor = dbapi_conn.cursor()
|
||||
cursor.execute("SET TIME ZONE 'Atlantic/Canary';")
|
||||
cursor.close()
|
||||
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
|
||||
# ============= CONFIGURACIÓN DE ZONA HORARIA =============
|
||||
import os
|
||||
os.environ['TZ'] = 'Atlantic/Canary'
|
||||
import time
|
||||
time.tzset()
|
||||
|
||||
# ============= LOGO CONFIGURABLE =============
|
||||
|
||||
from fastapi import FastAPI, File, UploadFile, Form, Depends, HTTPException, status
|
||||
|
||||
Reference in New Issue
Block a user