Handle all edge cases in DST detection code + tests