Fix calculations of time intervals

Bugfix for #65