Last week I noticed that when I tried to create a Date object in Swift using a Date Formatter and passing in a string with the date where DST starts in my country it would crash my app.<p>extension Date {<p><pre><code> static func fromString(_ string: String) -> Date {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-M-d"
return formatter.date(from: string)! ///Force unwrap because I never pass invalid strings.
}</code></pre>
}<p>Even though I was passing a valid string it still crashed because it couldn't parse it into a date. I solved the problem by adding a random hour to the date(All that mattered to me is the day/month/year so I just don't use the hour/minutes/seconds).<p>I wonder if it's the same bug causing a boot loop since it's being used by iOS itself.