I think memoizing is something to look into, but you will have to split the time-calculations into the date part and the time part. If you calculate and memoize the value for the date at 00:00 hour then you will benefit even if the dates are not sequential and you save yourself the burden of checking whether the date is indeed within the same day. One out of sequence log entry will "destroy" your cache, whereas memoize will not be bothered.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog:
Imperial Deltronics