Skip to content

DatePresetSchema

const DatePresetSchema: mutable<Struct<{
anchor: filter<typeof String$>;
end: optional<filter<typeof String$>>;
kind: Literal<["date"]>;
operator: SchemaClass<"before" | "after" | "between" | "is", "before" | "after" | "between" | "is", never>;
timeZone: filter<typeof String$>;
unit: SchemaClass<
| "millisecond"
| "second"
| "minute"
| "hour"
| "day"
| "week"
| "month"
| "quarter"
| "halfYear"
| "year",
| "millisecond"
| "second"
| "minute"
| "hour"
| "day"
| "week"
| "month"
| "quarter"
| "halfYear"
| "year", never>;
weekStartsOn: optional<filter<filter<typeof Number$>>>;
}>>;

Defined in: filters/schemas-effect.ts:196

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";
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)