]> matita.cs.unibo.it Git - helm.git/blob - helm/software/helena/src/lib/time.ml
7c59c22c5f810e5d90d58102d5a2bdb89e1ce311
[helm.git] / helm / software / helena / src / lib / time.ml
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department, University of Bologna, Italy.                     
5     ||I||                                                                
6     ||T||  HELM is free software; you can redistribute it and/or         
7     ||A||  modify it under the terms of the GNU General Public License   
8     \   /  version 2 or (at your option) any later version.              
9      \ /   This software is distributed as is, NO WARRANTY.              
10       V_______________________________________________________________ *)
11
12 module P = Printf
13 module L = Log
14
15 let level = 1 
16
17 let utime_stamp =
18    let old = ref 0.0 in
19    fun msg -> 
20       let times = Unix.times () in
21       let stamp = times.Unix.tms_utime in
22       let lap = stamp -. !old in
23       let str = P.sprintf "USR TIME STAMP (%s): %f (%f)" msg stamp lap in
24       L.warn level str;
25       old := stamp
26
27 let gmtime msg =
28    let gmt = Unix.gmtime (Unix.time ()) in
29    let yy = gmt.Unix.tm_year + 1900 in
30    let mm = gmt.Unix.tm_mon + 1 in
31    let dd = gmt.Unix.tm_mday in
32    let h = gmt.Unix.tm_hour in
33    let m = gmt.Unix.tm_min in
34    let s = gmt.Unix.tm_sec in
35    let str = P.sprintf "UTC TIME STAMP (%s): %u/%u/%u %u:%u:%u" msg yy mm dd h m s in
36    L.warn level str;