Fixed #296
(cherry picked from commit fdfa433)
Properly calculate time deltas (forgot the days)

Fixes #313
Merge pull request #3 from foosel/master

Merge recent foosel