package calendar

  1. Overview
  2. Docs

Precise Fcalendar printer. Seconds are rounded to integers before pretty printing. Default format is %i %T.

  • since 2.0

Generic type of a printer.

val fprint : string -> Format.formatter -> t -> unit

fprint format formatter x outputs x on formatter according to the specified format.

  • raises Invalid_argument

    if the format is incorrect.

val print : string -> t -> unit

print format is equivalent to fprint format Format.std_formatter

val dprint : t -> unit

Same as print d where d is the default format (see the printer implementations).

val sprint : string -> t -> string

sprint format date converts date to a string according to format.

val to_string : t -> string

Same as sprint d where d is the default format (see the printer implementations).

Parsers from string

val from_fstring : string -> string -> t

from_fstring format s converts s to a date according to format.

Date padding (i.e. a special directive following '%') and specifiers %e, %k and %l are not recognized. Specifiers %a, %A, %j, %v, %w and %W are recognized but mainly ignored: only the validity of the format is checked.

In order to recognize words (used by %a, %A, %b, %B and %p), a regular expression is used which can be configured by Printer.set_word_regexp. When the format has only two digits for the year number, 1900 are added to this number (see examples).

  • raises Invalid_argument

    if either the format is incorrect or the string does not match the format or the event cannot be created (e.g. if you do not specify a year for a date).

    @example from_fstring "the date is %D" "the date is 01/06/03" returns a date equivalent to Date.make 1903 1 6 @example from_fstring "the date is %B, the %dth %Y" "the date is May, the 14th 2007" returns a date equivalent to Date.make 2007 5 14 (with default internationalization).

val from_string : string -> t

Same as from_fstring d where d is the default format.