calc duration to sleep