X-Git-Url: http://git.annexia.org/?p=whenjobs.git;a=blobdiff_plain;f=lib%2Fwhenutils.ml;fp=lib%2Fwhenutils.ml;h=583d0302e25d6812d42d16dfa3be917dc7f83a0e;hp=7d20f759155ef69cb0450383318f51c92db19e35;hb=adc311d69459345a9ce23864d7aa41a7a6b97b42;hpb=b139baf5b616159972b0412a1794ac9e6e513196 diff --git a/lib/whenutils.ml b/lib/whenutils.ml index 7d20f75..583d030 100644 --- a/lib/whenutils.ml +++ b/lib/whenutils.ml @@ -50,3 +50,10 @@ let rec filter_map f = function match f x with | Some y -> y :: filter_map f xs | None -> filter_map f xs + +let string_of_time_t ?(localtime = false) t = + let tm = (if localtime then Unix.localtime else gmtime) t in + sprintf "%04d-%02d-%02d %02d:%02d:%02d%s" + (1900+tm.tm_year) (1+tm.tm_mon) tm.tm_mday + tm.tm_hour tm.tm_min tm.tm_sec + (if localtime then "" else " UTC")