@@ -13,7 +13,7 @@ let humanise_size size =
1313 humanise_size' (float_of_int size) 0
1414
1515let humanise_time timestamp =
16- let tm = Unix. gmtime timestamp in
16+ let tm = Unix. localtime timestamp in
1717 Printf. sprintf " %02d/%02d/%04d %02d:%02d" tm.tm_mday (tm.tm_mon + 1 )
1818 (tm.tm_year + 1900 ) tm.tm_hour tm.tm_min
1919
@@ -56,7 +56,7 @@ let generate_text file_name =
5656 strmodes := archive_entry_strmode entry :: ! strmodes;
5757 names := archive_entry_pathname_utf8 entry :: ! names;
5858 sizes := archive_entry_size entry :: ! sizes;
59- mtimes := PosixTypes.Time. to_int64 ( archive_entry_mtime entry) :: ! mtimes
59+ mtimes := archive_entry_mtime entry :: ! mtimes
6060 done ;
6161
6262 (* convert size to humanly readable *)
@@ -67,22 +67,37 @@ let generate_text file_name =
6767 else humanise_size @@ Int64. to_int size)
6868 ! sizes
6969 in
70- let human_dates =
71- List. map (fun t -> humanise_time @@ Int64. to_float t) ! mtimes
72- in
70+
7371 let max_size =
7472 List. fold_left (fun acc str -> max acc (String. length str)) 0 human_sizes
7573 in
7674
75+ let colorised_sizes =
76+ List. map
77+ (function
78+ | "-" -> Spectrum.Simple. sprintf " @{<grey-50>%s@}" " -"
79+ | str -> Spectrum.Simple. sprintf " @{<green>%s@}" str)
80+ human_sizes
81+ in
82+
83+ let colorised_dates =
84+ List. map
85+ (fun t ->
86+ Spectrum.Simple. sprintf " @{<yellow>%s@}"
87+ @@ humanise_time @@ Int64. to_float @@ PosixTypes.Time. to_int64 t)
88+ ! mtimes
89+ in
90+
7791 (* TODO: terminal colours *)
7892 let res =
7993 List. init (List. length ! strmodes) (fun i ->
80- let size = List. nth human_sizes i in
94+ let raw_size = List. nth human_sizes i in
95+ let size = List. nth colorised_sizes i in
8196 let strmode = List. nth ! strmodes i in
82- let mtime = List. nth human_dates i in
97+ let mtime = List. nth colorised_dates i in
8398 let name = List. nth ! names i in
8499 strmode ^ " "
85- ^ repeat " " (max_size - String. length size )
100+ ^ repeat " " (max_size - String. length raw_size )
86101 ^ size ^ " " ^ mtime ^ " " ^ name)
87102 |> String. concat " \n "
88103 in
@@ -95,6 +110,6 @@ let generate_cache cache_file text =
95110
96111let archive file_name =
97112 let cache_file = Helpers. get_cache_file file_name `TEXT in
98- if not @@ Sys. file_exists cache_file then
99- generate_cache cache_file (generate_text file_name);
113+ (* if not @@ Sys.file_exists cache_file then *)
114+ generate_cache cache_file (generate_text file_name);
100115 In_channel. with_open_text cache_file (print_endline << In_channel. input_all)
0 commit comments