module Printer:Pretty printing. In the following, an "event" is either a date or a time or a calendar.sig
..end
This module implements different printers: one for each kind of events.
The three printers have the same signature:
they mainly implement a fprint : string -> formatter -> t -> unit
function
and a from_fstring : string -> string -> t
function.
The first one prints an event according to a format string
(see below for a description of such a format).
The second one converts a string to an event according to a format string.
A format string follows the unix date utility (with few modifications).
It is a string which contains two types of objects: plain characters and
conversion specifiers. Those specifiers are introduced by
a %
character and their meanings are:
%%
: a literal %
%a
: short day name (by using a short version of day_name
)%A
: day name (by using day_name
)%b
: short month name (by using a short version of month_name
)%B
: month name (by using month_name
)%c
: shortcut for %a %b %d %H:%M:%S %Y
%d
: day of month (01..31)%D
: shortcut for %m/%d/%y
%e
: same as %_d
%h
: same as %b
%H
: hour (00..23)%I
: hour (01..12)%i
: shortcut for %Y-%m-%d
: ISO-8601 notation%j
: day of year (001..366)%k
: same as %_H
%l
: same as %_I
%m
: month (01..12)%M
: minute (00..59)%n
: a newline (same as \n
)%p
: AM or PM%r
: shortcut for %I:%M:%S %p
%S
: second (00..60)%t
: a horizontal tab (same as \t
)%T
: shortcut for %H:%M:%S
%V
: week number of year (01..53)%w
: day of week (1..7)%W
: same as %V
%y
: last two digits of year (00..99)%Y
: year (four digits)`%'
and a numeric directive are recognized:'-' (hyphen)
: do not pad the field'_' (underscore)
: pad the field with spaces
You can manage the string representations of days and months.
By default, the English names are used but you can change their by
setting the references day_name
and month_name
.
val day_name : (Date.day -> string) Pervasives.ref
val name_of_day : Date.day -> string
name_of_day d
is equivalent to !day_name d
.
Used by the specifier %A
.val short_name_of_day : Date.day -> string
short_name_of_day d
returns the 3 first characters of name_of_day d
.
Used by the specifier %a
.val month_name : (Date.month -> string) Pervasives.ref
val name_of_month : Date.month -> string
name_of_month m
is equivalent to !day_month m
.
Used by the specifier %B
.val short_name_of_month : Date.month -> string
short_name_of_month d
returns the 3 first characters of
name_of_month d
.
Used by the specifier %b
.val set_word_regexp : Str.regexp -> unit
from_fstring
. Default is [a-zA-Z]*
.module type S =sig
..end
module Date:S
with type t = Date.t
module DatePrinter:S
with type t = Date.t
module Time:S
with type t = Time.t
module TimePrinter:S
with type t = Time.t
module Ftime:S
with type t = Ftime.t
module Precise_Calendar:S
with type t = Calendar.Precise.t
module Calendar:S
with type t = Calendar.t
module CalendarPrinter:S
with type t = Calendar.t
module Precise_Fcalendar:S
with type t = Fcalendar.Precise.t
module Fcalendar:S
with type t = Fcalendar.t