Add get_time_range function

This is inspired by #61 and supercedes it.