format ranges relative to day start/end. better error handling