Spaces:
Sleeping
Sleeping
Bibhu Mishra
Claude Sonnet 4.6
fix: PDF proxy, 0-qty positions, portfolio chart dedup, SQLite UTC dates
73e0e3c Download api/src/common/sqlite-date.subscriber.ts from mishrabp/stockadvisor: direct link, hf CLI and curl.
- Browser
- Download file 915 Bytes
-
https://huggingface.co/spaces/mishrabp/stockadvisor/resolve/main/api/src/common/sqlite-date.subscriber.ts
- Command line
-
hf download hf://spaces/mishrabp/stockadvisor/api/src/common/sqlite-date.subscriber.ts
-
curl -L -o sqlite-date.subscriber.ts https://huggingface.co/spaces/mishrabp/stockadvisor/resolve/main/api/src/common/sqlite-date.subscriber.ts
915 Bytes
| import { EventSubscriber, EntitySubscriberInterface } from 'typeorm'; | |
| /** | |
| * SQLite stores Python's datetime.utcnow() as bare strings like | |
| * "2026-06-19 14:45:00.123456" (no timezone indicator). Node's Date | |
| * constructor treats these as LOCAL time, baking in the dev machine's | |
| * UTC offset before TypeORM sets the entity property. This subscriber | |
| * undoes that offset so all date fields are correct UTC, matching the | |
| * pg-type-parser fix on the PostgreSQL path. | |
| */ | |
| () | |
| export class SqliteDateSubscriber implements EntitySubscriberInterface { | |
| afterLoad(entity: object) { | |
| for (const [key, val] of Object.entries(entity)) { | |
| if (val instanceof Date && !isNaN(val.getTime())) { | |
| const offsetMs = val.getTimezoneOffset() * 60_000; | |
| if (offsetMs !== 0) { | |
| (entity as Record<string, unknown>)[key] = new Date(val.getTime() - offsetMs); | |
| } | |
| } | |
| } | |
| } | |
| } | |