> For AI agents: the complete documentation index is available at https://open-spaced-repetition.github.io/ts-fsrs/zh-TW/llms.txt, the full documentation bundle is available at https://open-spaced-repetition.github.io/ts-fsrs/zh-TW/llms-full.txt.

# Temporal Instant

將 `timezone` 和 `fractionalDays` 直接放在排程器 config 頂層，例如 `config: { ...modelConfig, timezone: 'Asia/Tokyo', fractionalDays: false }`。省略這兩個欄位時使用預設值 `'UTC'` 和 `false`。直接呼叫預設需要完整設定：`temporalInstantChrono.create({ config: { timezone: 'Asia/Tokyo', fractionalDays: false } })`；透過排程器建立實例時會驗證設定並補齊預設值。

`fractionalDays: false` 表示按指定時區計算日曆日期差；設為 `true` 時，時間差包含該時區下的小數天數。`add` 在 UTC 下使用固定 24 小時，在其他時區下按日曆天計算；跨越日光節約時間切換時，當地的一天可能短於或長於 24 小時。增加小數天數時，使用相鄰當地日的實際長度。此預設不提供自訂每日換日時間。

## 執行預設

在應用程式中安裝 `temporal-polyfill`。範例在建立 Chrono 前匯入全域入口，僅在執行環境沒有原生 Temporal 時安裝 polyfill；第二條 import 提供全域 TypeScript 型別宣告。


```sh [npm]
npm install temporal-polyfill
```

```sh [yarn]
yarn add temporal-polyfill
```

```sh [pnpm]
pnpm add temporal-polyfill
```

```sh [bun]
bun add temporal-polyfill
```

```sh [deno]
deno add npm:temporal-polyfill
```

```ts twoslash file="../../../snippets/run-code/chrono-temporal.ts"
import 'temporal-polyfill/global'
import 'temporal-polyfill/types/global'
import { temporalInstantChrono } from 'ts-fsrs'

const clock = temporalInstantChrono.create({
  config: { timezone: 'America/New_York', fractionalDays: false },
})
const fractionalClock = temporalInstantChrono.create({
  config: { timezone: 'America/New_York', fractionalDays: true },
})

// Noon in New York, the day before daylight saving time starts.
const from = Temporal.Instant.from('2026-03-07T17:00:00Z')
const next = clock.add(from, 1)
const halfDay = clock.add(from, 0.5)

console.log(
  JSON.stringify(
    {
      nextDayUTC: next.toString(),
      elapsedHours: from.until(next).total('hours'),
      calendarDays: clock.difference(from, next),
      fractionalDays: fractionalClock.difference(from, halfDay),
    },
    null,
    2
  )
)

```


▶ 執行程式碼

紐約 3 月 7 日中午對應 17:00 UTC。增加一個當地日曆天後，是 3 月 8 日中午，也就是 16:00 UTC；由於進入日光節約時間，實際只經過 23 小時。`fractionalDays: true` 將半天的增量計算為 `0.5`。
