Created
August 7, 2015 17:13
-
-
Save rizo/e2459845aaa730cab51c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let add_missing_hours | |
| : Date.t -> (Time.t * 'a) list -> (Time.t * 'a) list | |
| = fun date hourly_counts -> | |
| let gen_day_hours ~start = | |
| List.map (List.range 0 24) (fun hr -> Time.add start (Time.Span.create ~hr ())) in | |
| let day_hours = gen_day_hours | |
| ~start:(Time.of_date_ofday date Core.Ofday.start_of_day Core.Zone.utc) in | |
| List.fold day_hours ~init:hourly_counts | |
| ~f:(fun hourly_counts' hour -> | |
| if List.Assoc.mem hourly_counts' hour then hourly_counts' | |
| else List.Assoc.add hourly_counts' hour 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment