> On Jan 25, 2017, at 5:04 PM, Dennis Schafroth via swift-users 
> <swift-users@swift.org> wrote:
> 
> Hi
> 
> Trying to do some simple date parsing from syslog format (“Jan 25 20:21:22”) 
> into Date. Seem to work once but crashes on second call
> 
> 
> func dateConv(_ dateString: String) -> Date? {
>   let dateFormatter = DateFormatter()
>   dateFormatter.dateFormat = "MMM dd HH:mm"
>   dateFormatter.locale = Locale(identifier: "da_DK_POSIX")
>   if let date = dateFormatter.date(from: dateString) {
>     print("Real date: \(date)" )
>     return date
>   }
>   return nil
> }
> 
> var date  = dateConv("Jan 25 20:10")
> var date2 = dateConv("Jan 25 20:11”)

Check out your parentheses. The last one is a right curly quote not the 
straight ascii quote that it should be.

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to