- Timestamp:
- Dec 18, 2022, 2:49:25 PM (2 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/date.ml
r5 r43 16 16 Scanf.sscanf date "%4d-%02d-%02dT%02d:%02d:%02d" 17 17 (fun y mo d h mi s -> (y-1970)*31557600 + mo*2629800 + d*86400 + h*3600 + mi*60 + s) 18 let of_secs s = 19 let { Unix.tm_sec=seconds; tm_min=minutes; tm_hour=hours; 20 tm_mday=day; tm_mon=month; tm_year=year; _ } = Unix.localtime (float_of_int s) in 21 Printf.sprintf "%4d-%02d-%02dT%02d:%02d:%02d" 22 (year+1900) (month+1) day hours minutes seconds -
trunk/lib/header_pack.ml
r42 r43 85 85 | Msgpck.List (id::_time::title::_authors::_topics::[]) -> 86 86 (match to_id id with 87 | "" -> prerr_endline ("Invalid id for " ^Msgpck.to_string title); false87 | "" -> Printf.eprintf "Invalid id for %s" (Msgpck.to_string title); false 88 88 | id -> text.Text.id = id) 89 89 | _ -> prerr_endline ("Invalid record pattern"); false … … 106 106 in 107 107 fn i id t title authors topics references replies 108 | _ -> prerr_endline ("\n\nInvalid record structure\n\n")108 | x -> Printf.eprintf "Invalid record structure: %s\n%!" (Msgpck.show x) 109 109 110 let txt_fold_apply fn i m = 111 (* Printf.eprintf "%s\n%!" @@ Msgpck.show m;*) 112 match m with 110 let txt_fold_apply fn i = function 113 111 | Msgpck.List (id::time::title::authors::topics::extra) -> 114 112 let t = match time with Msgpck.Int i -> Int32.of_int i | Msgpck.Uint32 i -> i … … 116 114 let id = to_id id in 117 115 let title = Msgpck.to_string title in 118 let topics = t ry to_str_list topics with _e -> Printf.eprintf "topics %s" title; []in119 let authors = t ry to_str_list authors with _e -> Printf.eprintf "authors %s" title; []in116 let topics = to_str_list topics in 117 let authors = to_str_list authors in 120 118 let references, replies = begin match extra with 121 119 | [] -> [], [] 122 | refs::[] -> (try to_str_list refs, [] with e -> prerr_endline "fold ref"; raise e)120 | refs::[] -> to_str_list refs, [] 123 121 | refs::replies::_xs -> to_str_list refs, to_str_list replies 124 122 end 125 123 in 126 124 fn i id t title authors topics references replies 127 | x 125 | x -> Printf.eprintf "Invalid record structure: %s\n%!" (Msgpck.show x); i 128 126 129 let iteri fn pack = List.iteri (txt_iter_apply fn) (Msgpck.to_list pack.texts) 130 let fold fn init pack = List.fold_left (txt_fold_apply fn) init 131 (try Msgpck.to_list pack.texts with e -> prerr_string "Pack.fold"; raise e) 127 let iteri fn pack = List.iteri 128 (txt_iter_apply fn) 129 (Msgpck.to_list pack.texts) 130 131 let fold fn init pack = List.fold_left 132 (fun acc m -> try txt_fold_apply fn acc m with Invalid_argument x -> prerr_endline x; acc) init 133 (try Msgpck.to_list pack.texts with e -> prerr_string "Invalid pack.texts"; raise e)
Note:
See TracChangeset
for help on using the changeset viewer.