Carry explicit local date intervals instead of inferring the day from clock order. Cluster width, delivery, adoption, and reports keep the actual civil date; adopted date is stored separately from the reported birth_date. Algorithm identity is scoring-9 / spec-v5. Scoring weights, confirmation thresholds, and Skill version are unchanged. Isolated Linux final-3 gates passed; four pre-existing Python failures remain. This is not a production release.
26 lines
1021 B
TypeScript
26 lines
1021 B
TypeScript
type BirthDateRow = Readonly<{
|
|
birth_date?: unknown;
|
|
date?: unknown;
|
|
active_birth_date?: unknown;
|
|
activeDate?: unknown;
|
|
birth_time_status?: unknown;
|
|
birthTimeStatus?: unknown;
|
|
}>;
|
|
|
|
export function birthCalendarDate(value: unknown): string | undefined {
|
|
if (value instanceof Date && Number.isFinite(value.getTime())) return value.toISOString().slice(0, 10);
|
|
if (typeof value !== "string") return undefined;
|
|
const date = value.trim().slice(0, 10);
|
|
return /^\d{4}-\d{2}-\d{2}$/.test(date) ? date : undefined;
|
|
}
|
|
|
|
// Declaration date remains immutable input; adoption is a separate server-owned output.
|
|
export function effectiveBirthDate(row: BirthDateRow, useActive = true): string | undefined {
|
|
const declared = birthCalendarDate(row.birth_date ?? row.date);
|
|
const status = row.birth_time_status ?? row.birthTimeStatus;
|
|
if (useActive && (status === "accepted" || status === "confirmed")) {
|
|
return birthCalendarDate(row.active_birth_date ?? row.activeDate) ?? declared;
|
|
}
|
|
return declared;
|
|
}
|