Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

DateTime: toDate reads formatToParts by position, breaks on Hermes Android (no fractionalSecond part)

Chiusa Adatta ai principianti
#8,689 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@maricastroc ci sta già lavorando.

Dal 3/10/2026.

  • #8692 di @maricastroc — aperta
  • #8707 di @tim-smart — integrata

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
android, react-native, typescript
Ambito
mobile-dev

Direzione di ricerca

Inizia in internal/dateTime.ts, in toDate, dove l'output di formatToParts del formatter del fuso orario viene letto in base alla posizione. Riproduci il malfunzionamento con lo snippet Node fornito, quindi verifica che formatIsoDate restituisca la data locale prevista quando fractionalSecond è assente, anche su Hermes Android.

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

Descrizione

What version of Effect is running?

4.0.0 (also present on main)

What steps can reproduce the bug?

toDate in internal/dateTime.ts reads the zone formatter's formatToParts output by position: parts[0] is the month, parts[2] the year, through parts[6] for the fractional second. When the runtime's Intl leaves out a part, the indices shift and a later part, such as the time zone name, ends up in a numeric slot.

Hermes on Android does this. Its Java-backed Intl ignores fractionalSecondDigits, so no fractionalSecond part is emitted and parts[6] is the timeZoneName ("GMT+10:00"). Number("GMT+10:00") is NaN, the Date becomes invalid, and anything that formats it throws. In our React Native app, every DateTime.formatIsoDate on a zoned value threw on Android.

A Node repro that simulates the missing part:

import { DateTime } from "effect"

const formatToParts = Intl.DateTimeFormat.prototype.formatToParts
Intl.DateTimeFormat.prototype.formatToParts = function(date) {
  return formatToParts.call(this, date).filter((part) => part.type !== "fractionalSecond")
}

const zoned = DateTime.makeZonedUnsafe(new Date(), { timeZone: DateTime.zoneMakeLocal() })
DateTime.formatIsoDate(zoned)
What is the expected behavior?

"2026-10-03", or whatever the local date is.

What do you see instead?

RangeError: Invalid time value in Node. Hermes reports the same failure as RangeError: Date value out of bounds.

Additional information

Reading the parts by type fixes it, and falling back to the epoch's own milliseconds when fractionalSecond is absent is exact for any zone with a whole-second offset:

const parts: Partial<Record<Intl.DateTimeFormatPartTypes, string>> = {}
for (const part of self.zone.format.formatToParts(self.epochMilliseconds)) {
  parts[part.type] = part.value
}
const date = new Date(0)
date.setUTCFullYear(Number(parts.year), Number(parts.month) - 1, Number(parts.day))
date.setUTCHours(
  Number(parts.hour),
  Number(parts.minute),
  Number(parts.second),
  parts.fractionalSecond === undefined
    ? self.epochMilliseconds - Math.floor(self.epochMilliseconds / 1000) * 1000
    : Number(parts.fractionalSecond)
)

Hermes's Android Intl: lib/Platform/Intl/java/com/facebook/hermes/intl in facebook/hermes has no fractionalSecondDigits handling.

Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
10h 22m
PR unite (30g)
771

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.