For AI agents: the complete documentation index is available at https://open-spaced-repetition.github.io/ts-fsrs/ja-JP/llms.txt, the full documentation bundle is available at https://open-spaced-repetition.github.io/ts-fsrs/ja-JP/llms-full.txt, and this page is available as Markdown at https://open-spaced-repetition.github.io/ts-fsrs/ja-JP/guide/chrono/date.md.

Date

DefaultScheduler は dateChrono を使用します。時刻の schema は有効な Date オブジェクトを受け付けるため、保存した文字列やタイムスタンプは、スケジューラーに渡す前に Date に変換してください。現在の schema は new Date(0)(Unix エポックちょうどの時刻)と無効な日付も受け付けません。

スケジューラーの config 直下に fractionalDays を指定します(デフォルトは false)。直接呼ぶ場合は dateChrono.create({ config: { fractionalDays: false } }) とします。false では同じ UTC 日付内の差はゼロで、23:00 から翌日01:00 の差は1日です。true ではこの2時間は 2 / 24 日になります。add(from, 0.5) は常に12時間を加算します。正確な前後比較には compare を使ってください。

normalize とスケジューリング

normalize は card または revlog のフィールドを { previous, current } に変換します。Date と Temporal のプリセットでは、次のように使われます。

  • 復習時の normalize は previous: card.lastReviewAt と current: card.dueAt を返します。
  • 経過日数は difference(previous ?? current, now) です。New カードでは常にゼロです。
  • 新しい card は dueAt: add(now, interval) と lastReviewAt: now を保存します。
  • revlog は復習前の card の dueAt、lastReviewAt と、今回の reviewTime: now を保存します。
  • ロールバック時は previous: revlog.lastReviewAt と current: revlog.dueAt を返し、復習前の時刻フィールドを復元します。New カードの lastReviewAt は null に戻ります。

プリセットを実行する

import { 
const dateChrono: Chrono<{
    readonly time: SRSSchema<{
        input: Date;
        output: Date;
    }>;
    readonly config: SRSSchema<{
        input: {
            readonly fractionalDays?: boolean | undefined;
        };
        output: {
            readonly fractionalDays: boolean;
        };
    }>;
    readonly fields: {
        readonly card: SRSSchema<{
            input: {
                dueAt: Date;
                lastReviewAt?: (Date | null) | undefined;
            };
            output: {
                dueAt: Date;
                lastReviewAt: Date | null;
            };
        }>;
        readonly revlog: SRSSchema<{
            input: {
                dueAt: Date;
                lastReviewAt?: (Date | null) | undefined;
                reviewTime: Date;
            };
            output: {
                dueAt: Date;
                lastReviewAt: Date | null;
                reviewTime: Date;
            };
        }>;
    };
}>
dateChrono
} from 'ts-fsrs'
const
const clock: ChronoCore<Date>
clock
=
const dateChrono: Chrono<{
    readonly time: SRSSchema<{
        input: Date;
        output: Date;
    }>;
    readonly config: SRSSchema<{
        input: {
            readonly fractionalDays?: boolean | undefined;
        };
        output: {
            readonly fractionalDays: boolean;
        };
    }>;
    readonly fields: {
        readonly card: SRSSchema<{
            input: {
                dueAt: Date;
                lastReviewAt?: (Date | null) | undefined;
            };
            output: {
                dueAt: Date;
                lastReviewAt: Date | null;
            };
        }>;
        readonly revlog: SRSSchema<{
            input: {
                dueAt: Date;
                lastReviewAt?: (Date | null) | undefined;
                reviewTime: Date;
            };
            output: {
                dueAt: Date;
                lastReviewAt: Date | null;
                reviewTime: Date;
            };
        }>;
    };
}>
dateChrono
.
Chrono<{ readonly time: SRSSchema<{ input: Date; output: Date; }>; readonly config: SRSSchema<{ input: { readonly fractionalDays?: boolean | undefined; }; output: { readonly fractionalDays: boolean; }; }>; readonly fields: { readonly card: SRSSchema<{ input: { dueAt: Date; lastReviewAt?: (Date | null) | undefined; }; output: { dueAt: Date; lastReviewAt: Date | null; }; }>; readonly revlog: SRSSchema<{ input: { dueAt: Date; lastReviewAt?: (Date | null) | undefined; reviewTime: Date; }; output: { dueAt: Date; lastReviewAt: Date | null; reviewTime: Date; }; }>; }; }>.create: (ctx: {
    readonly config: {
        readonly fractionalDays: boolean;
    };
}) => ChronoCore<Date>
create
({ config: { fractionalDays: false } })
const from = new Date('2026-01-01T23:00:00.000Z') const to = new Date('2026-01-02T01:00:00.000Z') console.log( JSON.stringify({ elapsedDays:
const clock: ChronoCore<Date>
clock
.
ChronoCore<Date>.difference: (from: Date, to: Date) => number

Returns the distance from the previous review time to the current time.

difference
(from, to),
halfDayLater:
const clock: ChronoCore<Date>
clock
.
ChronoCore<Date>.add: (from: Date, days: number) => Date
add
(from, 0.5).toISOString(),
order:
const clock: ChronoCore<Date>
clock
.
ChronoCore<Date>.compare?: ((left: Date, right: Date) => number) | undefined

Compares two time values in chronological order.

Returns a negative number when left is earlier than right, zero when they are equal, and a positive number when left is later than right. Callers decide how to compare values when a chronology omits this method.

compare
?.(from, to),
}) )

UTC の日付をまたぐと日付差は1日になります。半日を加算すると、時刻は12時間後に進みます。