From e74131b3a055fe3f3333030d8459275436f37a40 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 29 Jul 2011 19:53:19 +0100 Subject: [PATCH] Use the Calendar module. --- Makefile.am | 2 +- configure.ac | 5 +++++ filetree_markup.ml | 10 ++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index ac197c4..dbb23a5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -121,7 +121,7 @@ XOBJECTS = $(OBJECTS:.cmo=.cmx) bin_SCRIPTS = guestfs-browser OCAMLPACKAGES = \ - -package libvirt,guestfs,hivex,lablgtk2,extlib,xml-light,camomile,threads,bitstring,bitstring.syntax -syntax bitstring + -package libvirt,guestfs,hivex,lablgtk2,extlib,xml-light,calendar,camomile,threads,bitstring,bitstring.syntax -syntax bitstring OCAMLCFLAGS = \ -g \ -warn-error CDEFLMPSUVYZX \ diff --git a/configure.ac b/configure.ac index 3a0b364..722832d 100644 --- a/configure.ac +++ b/configure.ac @@ -78,6 +78,11 @@ if test "$OCAML_PKG_xml_light" = "no"; then AC_MSG_ERROR([Please install OCaml module 'xml-light'.]) fi +AC_CHECK_OCAML_PKG([calendar]) +if test "$OCAML_PKG_calendar" = "no"; then + AC_MSG_ERROR([Please install OCaml module 'calendar'.]) +fi + AC_CHECK_OCAML_PKG([camomile]) if test "$OCAML_PKG_camomile" = "no"; then AC_MSG_ERROR([Please install OCaml module 'camomile' (>= 0.8, including the data module if that is separate).]) diff --git a/filetree_markup.ml b/filetree_markup.ml index b5728fa..84c4288 100644 --- a/filetree_markup.ml +++ b/filetree_markup.ml @@ -25,6 +25,8 @@ open Slave_types open Printf +module CL = CalendarLib + (* Base colours. XXX Should be configurable somewhere. *) let file_color = 0x20, 0x20, 0xff (* regular file *) let dir_color = 0x80, 0x80, 0x20 (* directory *) @@ -149,10 +151,10 @@ let markup_of_date t = let t = Int64.to_float t in let show_full_date () = - let tm = localtime t in - sprintf "%04d-%02d-%02d %02d:%02d:%02d" - (tm.tm_year + 1900) (tm.tm_mon + 1) tm.tm_mday - tm.tm_hour tm.tm_min tm.tm_sec + let cal = CL.Calendar.from_unixfloat t in + let cal = CL.Calendar.convert cal CL.Time_Zone.UTC CL.Time_Zone.Local in + CL.Printer.Calendar.sprint + "%F %T" cal in (* How long ago? *) -- 1.8.3.1