lanonna/pam/bin/utils.ml

25 lines
729 B
OCaml
Raw Normal View History

2024-03-16 09:34:29 +01:00
open Unix
let now () =
let current_time = time () in
let human_time = localtime current_time in
let year = 1900 + human_time.tm_year in
let month = human_time.tm_mon + 1 in
let day = human_time.tm_mday in
let hour = human_time.tm_hour in
let minute = human_time.tm_min in
let second = human_time.tm_sec in
Printf.sprintf "%04d-%02d-%02d %02d:%02d:%02d"
year month day hour minute second
2024-03-25 14:17:34 +01:00
let unhandled m = [%string "Runtime failure: unhandled %{Batteries.dump m}"] |> print_endline; exit 2
let one_second = 1_000_000L
2024-04-02 14:38:00 +02:00
let exit2 msg = let _ = print_endline msg in exit 2
module StringMap = Map.Make (String)
2024-04-24 09:58:14 +02:00
let rec all acc = function [] -> Ok acc | Ok x::xs -> all (x::acc) xs | Error e::_ -> Error e