Module Prelude_time

Time and Date Functions

See: Misha Wolf and Charles Wicksteed, Date and Time Formats, September 15, 1997

exception Parse_error of string

raised when there is an error in strftime or convert's format string

exception NYI of string

raised when a strftime %-escape is Not Yet Implemented

val weekdayname : int -> string

convert an integer 0..6 to the name of a weekday (0 = Sunday)

val monthname : int -> string

convert an integer 0..11 to the name of a month (0 = January)

val gmtime : unit -> Unix.tm

gmtime (): return the Greenwich Mean Time (GMT / UTC +0) for now.

val localtime : unit -> Unix.tm

localtime (): return the localtime for now.

val tz : unit -> int * int

tz (): return local timezone as (hours,minutes) offset from zulu.

val strftime : ?tz:(int * int) -> string -> Unix.tm -> string

format date and time (pure-ocaml implementation of Posix strftime(3))

Bugs:

  • Locale-specific escapes are hard-wired to EN_US
  • %U %V %W escapes are Not Yet Implemented and raise NYI
  • parameter tz

    time zone as (hours,minutes) offset from zulu

  • parameter fmt

    string with %-escapes to format

  • parameter tm

    Unix.tm record representing the time

  • returns

    formatted string

  • raises NYI

    for %-escapes that are Not Yet Implemented: 'U', 'V', 'W'

val w3c : string

w3c time format %Y-%m-%dT%H:%M:%S