Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

クローズ 初心者向け
#8,689 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@maricastroc がすでに取り組んでいます。

2026年10月3日 から。

  • #8692 @maricastroc による — オープン
  • #8707 @tim-smart による — マージ済み

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
android, react-native, typescript
領域
mobile-dev

調査の方向性

internal/dateTime.ts の toDate から始めます。ここでは、ゾーンフォーマッターの formatToParts の出力が位置によって読み取られています。提供された Node スニペットで失敗を再現し、fractionalSecond がない場合に formatIsoDate が期待されるローカル日付を返すことを、Hermes Android 上でも確認してください。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
16.7k
フォーク
808
平均マージ
10時間 33分
マージ済み PR(30日)
830

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Effect-TS/effect のほかの issue

Effect-TS/effect の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。