EdtfDate

EdtfDate :: # (opaque)

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.

from_quote : Str -> Try(EdtfDate, [BadQuotedBytes(Str)])

Typed quoted literals use the same checked profile at compile time. Runtime interpolation remains Str followed by an explicit parse call.

profile : Str

Identifier of the supported text profile described above; it does not imply support for the entire standard.

parse : Str -> Try(EdtfDate, Error)

Parses a Gregorian year, year-month or full date with supported scoped qualifiers. Rejects excluded EDTF forms explicitly; never invents omitted components.

from_description : QualifiedCalendarValue -> Try(EdtfDate, Error)

Checks that a qualified native description fits this Gregorian date-only profile, including year range and qualifier scopes.

description : EdtfDate -> QualifiedCalendarValue

Returns the qualified calendar description, preserving resolution and independent qualifier scopes without assigning an uncertainty tolerance.

to_text : EdtfDate -> Str

Canonical EDTF date text preserving resolution and qualifier meaning; the original placement or spelling of equivalent qualifiers need not survive.

is_eq : EdtfDate, EdtfDate -> Bool

Compares calendar descriptions, resolution and qualifiers, not a guessed interval of possible dates.

to_hash : EdtfDate, Hasher -> Hasher

Hashes the same declaration fields used by is_eq, so equal values are interchangeable as dictionary keys.

fact_count : EdtfDate -> U64

Number of indexed semantic facts available through fact_at.

fact_at : EdtfDate, U64 -> [End, Item(SemanticFact)]

Returns the zero-based semantic fact, or End when the index is outside fact_count. Facts describe meaning, not a serialized record.

to_inspect : EdtfDate -> Str

A concise semantic summary for debugging. Use the standard text encoder for storage or interchange.

Error : [Malformed, Incomplete, TooLarge, OutOfRange, UnsupportedForm, UnsupportedCalendar, UnsupportedResolution, UnsupportedQualification]

Distinguishes malformed or incomplete input, size/range limits, and unsupported calendar, resolution or qualification.