V1.TemporalTemporal validity support for time-bounded fields.
Temporal validity support for contact fields.
This module provides types and functions for managing time-bounded information in contacts, such as emails valid only during certain employment periods.
type date = Ptime.dateDate represented as a Ptime.date tuple (year, month, day).
When parsing from strings, partial dates are normalized:
"2001" → (2001, 1, 1)"2001-01" → (2001, 1, 1)"2001-01-15" → (2001, 1, 15)val parse_date_string : string -> date optionparse_date_string s parses an ISO 8601 date string.
Accepts various formats with partial date support:
Returns None if the string is not a valid date format.
val format_date : date -> stringformat_date date formats a date as ISO 8601 (YYYY-MM-DD).
Example: format_date (2001, 1, 15) returns "2001-01-15"
type range = {from : date option;Start date (inclusive). None means from the beginning.
until : date option;End date (exclusive). None means continuing/indefinite.
}A temporal range indicating validity period.
val always : rangealways is a range that is always valid (no from/until bounds).
valid_at range ~date checks if range is valid at the given date.
None range means always validNone from means valid from beginningNone until means valid continuingval is_current : range option -> boolis_current range checks if range is valid at the current date. Uses today's date for the check.
val current : get:('a -> range option) -> 'a list -> 'a optioncurrent ~get list returns the first current/valid item from list.
at_date ~get ~date list filters list to items valid at date.
val filter :
get:('a -> range option) ->
from:date option ->
until:date option ->
'a list ->
'a listfilter ~get ~from ~until list filters list to items overlapping the period.
Returns items whose temporal range overlaps with the given period.