I need to write a function that takes two timestamps and segment the time range in Days, Hours and Seconds in that order. To walk through an example, lets say the input to our function is
val start = 08-01-14 12:30:00 val end = 08-04-14 12:30:00
our function will return
min -> (08-01-14 12:30:00, 08-01-14 13:00:00)
hour -> (08-01-14 13:00:00, 08-01-14 24:00:00)
day -> (08-02-14 00:00:00, 08-03-14 24:00:00)
hour -> (08-04-14 00:00:00, 08-04-14 12:00:00)
min -> (08-04-14 12:00:00, 08-04-14 12:30:00)
I have hand rolled an implementation that works but its a little kludgy, I am looking for a) is there a library that already does that? b) if not, what would be the best way to implement this?