Export timestamps shift by the server's UTC offset

Aperta Adatta ai principianti
#162 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
86/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bun, sqlite, typescript
Ambito
backend, data

Direzione di ricerca

Leggi packages/contract/src/export-columns.ts e packages/api/src/lib/datetime.ts, in particolare formatTimestamp e parseStoredTimestamp. Aggiungi un test per un timestamp memorizzato senza fuso orario, impostando il fuso orario del processo su un fuso diverso da UTC, ed esegui i test pertinenti del formatter. Il lavoro è completato quando i timestamp esportati corrispondono all’ora UTC memorizzata in tutti i fusi orari.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

needs-triage

What happens

On a server whose clock isn't set to UTC, the created and last_updated columns in exports are shifted by the server's UTC offset. On a machine set to US Pacific time, a Container stored as created at 2026-11-29 16:46:31 (UTC) exports as 2026-11-30T00:46:31.000Z, 8 hours late.

The web export and the Claude Code export share the same code and both show the shift. It happens on main, so #161 didn't introduce it.

Cause

Timestamps are stored as UTC text with no time zone (YYYY-MM-DD HH:MM:SS, from toStoredTimestamp in packages/api/src/lib/datetime.ts). formatTimestamp in packages/contract/src/export-columns.ts runs new Date(value) on that text, and JavaScript reads text in that form as local time. parseStoredTimestamp in datetime.ts already handles this by adding Z, but the contract formatter doesn't use it.

formatDateOnly in the same file falls back to new Date(value) the same way, but the earlier regex catches stored values first, so it probably doesn't shift in practice.

How to reproduce

  1. On a Mac set to Pacific time, seed a demo database: DATABASE_PATH=/tmp/demo.sqlite bun packages/api/src/lib/demo-seed.ts.
  2. Start the API on that database, log in as admin, and request GET /api/export/containers?study=DEMO01&format=csv.
  3. Compare the created column with select created from storage_container in the database.

Fix

Read stored timestamps as UTC in formatTimestamp, the same way parseStoredTimestamp does. Add a test that pins the result for a zoneless value, with the process time zone set to somewhere other than UTC.

Who it affects

Any instance whose server clock isn't set to UTC. Docker images usually run in UTC, so a containerized deployment may not show it. Local development on a laptop does.

Lingua principale
TypeScript
Stelle
0
Fork
0
Merge medio
8g 47m
PR unite (30g)
3

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di EPPIcenter/sampledb3

Tutte le issue di EPPIcenter/sampledb3

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.