Use the Calendar module.
[guestfs-browser.git] / filetree_markup.ml
index b5728fa..84c4288 100644 (file)
@@ -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 "<span color=\"#222222\" size=\"small\">%04d-%02d-%02d %02d:%02d:%02d</span>"
-      (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
+      "<span color=\"#222222\" size=\"small\">%F %T</span>" cal
   in
 
   (* How long ago? *)