Fix bug in time conversions