From 618eadb4335ce3af1c3060091d86e3c55debef77 Mon Sep 17 00:00:00 2001 From: Yves Gugger Date: Sat, 20 Dec 2025 21:31:30 +0100 Subject: [PATCH] fix: Auction end_time timezone - add UTC suffix The frontend was calculating wrong time remaining because end_time was sent without timezone suffix (Z). JavaScript's new Date() interprets "2025-12-20T20:49:20" as local time, but the server stores it as UTC. Fix: Add json_encoders to Pydantic models that append "Z" to all datetime fields, marking them as UTC. Affected models: - AuctionListing - AuctionSearchResponse - MarketFeedItem - MarketFeedResponse - ScrapeStatus --- backend/app/api/auctions.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/backend/app/api/auctions.py b/backend/app/api/auctions.py index 8eb17fc..d293302 100644 --- a/backend/app/api/auctions.py +++ b/backend/app/api/auctions.py @@ -78,6 +78,10 @@ class AuctionListing(BaseModel): class Config: from_attributes = True + # Serialize datetimes as ISO format with UTC timezone suffix + json_encoders = { + datetime: lambda v: v.isoformat() + "Z" if v else None + } class AuctionSearchResponse(BaseModel): @@ -92,6 +96,11 @@ class AuctionSearchResponse(BaseModel): "$50 × Length × TLD × Keyword × Brand factors. " "See /portfolio/valuation/{domain} for detailed breakdown." ) + + class Config: + json_encoders = { + datetime: lambda v: v.isoformat() + "Z" if v else None + } class PlatformStats(BaseModel): @@ -108,6 +117,11 @@ class ScrapeStatus(BaseModel): total_auctions: int platforms: List[str] next_scrape: Optional[datetime] + + class Config: + json_encoders = { + datetime: lambda v: v.isoformat() + "Z" if v else None + } class MarketFeedItem(BaseModel): @@ -146,6 +160,9 @@ class MarketFeedItem(BaseModel): class Config: from_attributes = True + json_encoders = { + datetime: lambda v: v.isoformat() + "Z" if v else None + } class MarketFeedResponse(BaseModel): @@ -157,6 +174,11 @@ class MarketFeedResponse(BaseModel): sources: List[str] last_updated: datetime filters_applied: dict = {} + + class Config: + json_encoders = { + datetime: lambda v: v.isoformat() + "Z" if v else None + } # ============== Helper Functions ==============