Format dates with the app's locale instead of toLocaleDateString()

Aperta
#3,707 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@vaishnavi-codeworld ci sta già lavorando.

Dal 26/11/2026.

  • #3924 di @vaishnavi-codeworld — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nextjs, react, typescript

Direzione di ricerca

Start by running the grep in the issue to list the 13 toLocaleDateString()/toLocaleString() calls, mostly in src/components/repo-analytics/, PRMetrics.tsx, GoalTracker.tsx and MilestonePlanner.tsx. Check how next-intl supplies the locale through useLocale() on the client and getLocale() on the server, then add the shared formatDate helper under src/lib/ using Intl.DateTimeFormat. Done when the grep returns nothing and the helper's unit tests pass, including a case near midnight UTC.

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

Descrizione

level 2 level:intermediate status:assigned type:refactor
Summary

13 places call toLocaleDateString() / toLocaleString() with no locale, so dates follow the browser's language, not the language picked in DevTrack, and the server and client can render different text (hydration warnings).

Where
grep -rnE "toLocale(Date|Time)?String\(\)" src --include=*.tsx

Most are in src/components/repo-analytics/, PRMetrics.tsx, GoalTracker.tsx and MilestonePlanner.tsx.

Expected outcome

A small shared helper (e.g. formatDate(date, locale, options) in src/lib/) built on Intl.DateTimeFormat, used everywhere, with the locale coming from next-intl (useLocale() on the client, getLocale() on the server). Pass timeZone: "UTC" wherever a date-only value is shown, so it doesn't shift by a day.

Acceptance criteria
  • No bare toLocale*String() calls left
  • Unit tests for the helper, including a date near midnight UTC
Lingua principale
TypeScript
Stelle
246
Fork
436
Merge medio
9h 33m
PR unite (30g)
213

Preparare l'ambiente

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 Priyanshu-byte-coder/devtrack

Tutte le issue di Priyanshu-byte-coder/devtrack

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.