fechero
v0.2.1
Published
Structured Spanish date parsing for scheduling engines.
Maintainers
Readme
fechero
Structured Spanish date parsing for scheduling engines.
fechero is a deterministic parser for informal Spanish temporal expressions, designed for booking flows and WhatsApp-style input. It keeps ambiguity explicit, records conservative typo corrections, and returns structured candidates instead of a single opaque Date.
What it handles today
- Relative dates like
hoy,mañana,pasado mañana - Absolute dates like
9 de abrilandjueves 9 de abril - Broad ranges like
la semana que vieneandfinde - Human week expressions like
esta semana,la otra semana,este jueves,el martes que viene - Weekdays like
martesand ambiguous phrases likepróximo viernes - Exact clock times like
a las 16:30,16:30, and approximate times liketipo 3 - Named time ranges like
a la mañanaanda la tarde - Open-ended constraints like
después de las 18andantes de las 18 - Weekly recurrence like
todos los martes - Negative constraints like
excepto los martesorlos martes a la mañana no puedo - Conservative typo handling using explicit replacements plus Levenshtein matching over a small temporal lexicon
Install
pnpm add fecheroUsage
import { parseSpanishDate, resolveBestCandidate } from "fechero";
const parsed = parseSpanishDate("próximo viernes", {
referenceDateTime: "2026-03-31T10:00:00-03:00",
timezone: "America/Argentina/Buenos_Aires",
locale: "es-AR",
});
console.log(parsed.candidates);
console.log(resolveBestCandidate(parsed));import { parseSpanishDate, toTemporalOutput } from "fechero";
parseSpanishDate("los martes a la mañana no puedo", {
referenceDateTime: "2026-03-31T10:00:00-03:00",
timezone: "America/Argentina/Buenos_Aires",
locale: "es",
});
// {
// normalizedText: "los martes a la manana no puedo",
// corrections: [],
// candidates: [
// {
// kind: "availability_filter",
// excludedWeekdays: [2],
// timeRange: { from: "08:00", to: "12:00", label: "manana", precision: "coarse" }
// }
// ],
// warnings: [],
// errors: []
// }
const parsed = parseSpanishDate("este jueves a la tarde", {
referenceDateTime: "2026-03-31T10:00:00-03:00",
timezone: "America/Argentina/Buenos_Aires",
locale: "es",
});
toTemporalOutput(parsed, {
weekdayConvention: "sunday-0",
preserveAmbiguity: true,
});Result shape
parseSpanishDate() returns:
normalizedTextcorrections[]candidates[]warnings[]errors[]
Candidate kinds currently exposed:
datedatetimedate_rangeavailability_filterrecurrence
Candidate metadata currently exposed:
exactStartTimeisApproximatesourceSpanswarnings
Scheduling helpers:
toTemporalOutput()toAvailabilityFilters()toExclusionFilters()toTemporalConstraints()
Design notes
- The parser is deterministic. It does not depend on an LLM.
- Typo correction is intentionally conservative and limited to a domain lexicon.
- Ambiguous expressions stay ambiguous in the output.
- A separate resolver helper is available when a consumer wants a single best candidate.
- Weekday output conventions can be adapted in helpers, including
sunday-0for common scheduling systems. - Absolute date + weekday contradictions emit
WEEKDAY_DATE_MISMATCH.
Current limits
- v1.1 is optimized for
es-AR, but accepts broadereslocale input - The lexicon and rule set are still intentionally small
- Expressions that require external calendars, holidays, or locale-specific business logic are not resolved yet
Development
pnpm test
pnpm typecheck
pnpm buildRelease
pnpm release:check
pnpm release:dry-run
pnpm release:publishNotes:
release:checkruns typecheck, tests, build, andnpm pack --dry-runrelease:dry-runexercises the npm publish flow without pushing to npmrelease:publishpublishes with public access once the repo is ready- once the remote repository exists, add
repository,homepage, andbugsfields topackage.json
