package caldav

  1. Overview
  2. Docs

The CLOCK module signature defines a clock source, that is used with the Webmachine.Make(IO)(Clock) functor.

Examples:

(* static mock time *) module MockClock = struct let now = fun () -> 1526322704 end

(* using Unix.gettimeofday *) module UnixClock = struct let now = fun () -> int_of_float (Unix.gettimeofday ()) end

(* using Ptime_clock, which uses the system POSIX clock/gettimeofday *) module PtimeClock = struct let now = fun () -> int_of_float (Ptime.to_float (Ptime_clock.now ())) end

(* using mirage-clock in MirageOS unikernels *) module MirageClock = struct let now = fun () -> let d, ps = Pclock.now_d_ps clock in let days_in_seconds = d * 86_400 in let picos_in_seconds = Int64.(to_int (div ps (1_000_000_000_000L))) i days_in_seconds + picos_in_seconds end

val now : unit -> int
OCaml

Innovation. Community. Security.