package core_kernel

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

This module is only used in the implementation of ofday.ml, and isn't exposed as a submodule of Core_kernel.

val parse : Base.String.t -> f: (Base.String.t -> hr:Base.Int.t -> min:Base.Int.t -> sec:Base.Int.t -> subsec_pos:Base.Int.t -> subsec_len:Base.Int.t -> 'a) -> 'a

Parses a given time-of-day string. If the string is invalid, raises. If the string is valid, calls f with the string, the parsed numbers of hours, minutes, and seconds, and the position and length of the substring representing subseconds, which can be parsed with the appropriate precision for a given representation.

The substring String.sub string ~pos:subsec_pos ~len:subsec_len will be either the empty string (representing zero) or a decimal point ('.') and one or more digits and/or underscores (representing a fractional number of seconds in decimal notation).

Illegal hours, minutes, or seconds values are rejected by parse, as are times with the hour of 24 and non-zero minutes or seconds. The time "24:00:00" itself is accepted. If seconds is 60 (a leap second), the client will be passed ~subsec_len:0 regardless of the subsecond part.

val parse_iso8601_extended : ?pos:Base.Int.t -> ?len:Base.Int.t -> Base.String.t -> f: (Base.String.t -> hr:Base.Int.t -> min:Base.Int.t -> sec:Base.Int.t -> subsec_pos:Base.Int.t -> subsec_len:Base.Int.t -> 'a) -> 'a

As parse, for strings in ISO 8601 extended format. Allows substring parsing via ~pos and ~len arguments.

val invalid_string : Base.String.t -> reason:Base.String.t -> _

Raises ofday-parsing errors for the given string, annotated with the given reason. Useful inside the ~f argument to parse in order to generate error messages that are consistent with what parse raises.

val am_suffixes : Base.String.t Base.List.t Lazy.t

Allowed AM/PM suffixes; useful for testing.

val pm_suffixes : Base.String.t Base.List.t Lazy.t