Parsing is bounded by 64 UTF-8 bytes. Valid partial grammar prefixes return
Incomplete. Invalid fields/grammar return Malformed. Selected recognized
excluded forms (negative year, long year, year-only mask) return UnsupportedForm;
recognition does not validate every excluded EDTF feature. Native conversion
checks calendar, resolution, year range and qualifier scope explicitly.
Generic codecs use canonical strings and typed literals validate at compile time:
import time.EdtfDate
expect {
date : EdtfDate
date = "1984?"
parsed : Try({ date : EdtfDate }, [InvalidJson(Str), MissingRequiredField(Str), Encoding([InvalidJson(Str)]), InvalidEdtfDate(EdtfDate.Error)])
parsed = Json.parse(Json.to_str({ date: date }))
parsed == Ok({ date: date })
}
parser_for : encoding -> (state -> Try({ value : EdtfDate, rest : state }, [InvalidEdtfDate(Error), Encoding(err), ..]))
where [
encoding.parse_str : encoding, state -> Try({ value : Str, rest : state }, err),
]
Decode one encoded string using this type's text parser.
Encoding failures remain distinct from this profile's validation errors.
The encoding owns framing and its work limits; parse bounds the decoded text.
encoder_for : encoding -> (EdtfDate, state -> Try(state, err))
where [
encoding.encode_str : Str, state -> Try(state, err),
]
Encodes the canonical standard text as a string in the selected encoding; encoding failures pass through.
Parses a Gregorian year, year-month or full date with supported scoped qualifiers. Rejects excluded EDTF forms explicitly; never invents omitted components.