Skip to content

DatePresetSchema

const DatePresetSchema: Struct<{
anchor: mutableKey<String>;
end: mutableKey<optionalKey<String>>;
kind: mutableKey<Literal<"date">>;
operator: mutableKey<Literals<readonly ["is", "before", "after", "between"]>>;
timeZone: mutableKey<String>;
unit: mutableKey<Literals<readonly ["millisecond", "second", "minute", "hour", "day", "week", "month", "quarter", "halfYear", "year"]>>;
weekStartsOn: mutableKey<optionalKey<Number>>;
}>;

Defined in: filters/schemas-effect-v4.ts:199

Validates a date period preset (the model’s DatePreset): operator (is/before/after/between), unit, a real IANA timeZone, a Temporal.PlainDateTime string anchor (and optional end), and an optional weekStartsOn integer 0–6. The anchor is a wall-clock time read in timeZone, not an instant (a Z-suffixed string is rejected); a date-only "2026-02-01" is accepted as midnight.

import { Schema } from "effect";
import { DatePresetSchema } from "@xtandard/lib/filters/effect/v4";
const input = {
kind: "date", operator: "is", unit: "month",
timeZone: "America/Los_Angeles", anchor: "2026-02-01T00:00:00",
};
Schema.decodeUnknownSync(DatePresetSchema)(input);
// → `input`, typed as `DatePreset`
Schema.is(DatePresetSchema)({ ...input, timeZone: "Mars/Olympus" });
// → false (not an IANA zone)