<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">That why I am choosing to use an IDE. It shows the typos.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 26, 2017 at 7:53 AM, Michael Bauer via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><span></span></div><div><span class=""><div></div><div><br></div><div><br>On Jan 25, 2017, at 5:04 PM, Dennis Schafroth via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div>Hi<div><br></div><div>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</div><div><br></div><div><div style="margin:0px;font-size:14px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><br></div></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><div style="margin:0px;line-height:normal;color:rgb(205,121,35)"><span style="font-variant-ligatures:no-common-ligatures;color:#d03bff">func</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">dateConv</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">(</span><span style="font-variant-ligatures:no-common-ligatures">_</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">dateString</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">: </span><span style="font-variant-ligatures:no-common-ligatures;color:#34a327">String</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">) -> </span><span style="font-variant-ligatures:no-common-ligatures;color:#34a327">Date</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">? {</span></div><div style="margin:0px;line-height:normal;color:rgb(205,121,35)"><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#d03bff">let</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">dateFormatter</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> = </span><span style="font-variant-ligatures:no-common-ligatures;color:#34a327">DateFormatter</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">()</span></div><div style="margin:0px;line-height:normal;color:rgb(205,121,35)"><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">dateFormatter</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">.</span><span style="font-variant-ligatures:no-common-ligatures">dateFormat</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> = </span><span style="font-variant-ligatures:no-common-ligatures;color:#af3782">"MMM dd HH:mm"</span></div><div style="margin:0px;line-height:normal;color:rgb(205,121,35)"><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">dateFormatter</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">.</span><span style="font-variant-ligatures:no-common-ligatures">locale</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> = </span><span style="font-variant-ligatures:no-common-ligatures;color:#34a327">Locale</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">(</span><span style="font-variant-ligatures:no-common-ligatures">identifier</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">: </span><span style="font-variant-ligatures:no-common-ligatures;color:#af3782">"da_DK_POSIX"</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">)</span></div><div style="margin:0px;line-height:normal;color:rgb(205,121,35)"><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#d03bff">if</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#d03bff">let</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">date</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> = </span><span style="font-variant-ligatures:no-common-ligatures">dateFormatter</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">.</span><span style="font-variant-ligatures:no-common-ligatures">date</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">(</span><span style="font-variant-ligatures:no-common-ligatures">from</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">: </span><span style="font-variant-ligatures:no-common-ligatures">dateString</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">) {</span></div><div style="margin:0px;line-height:normal;color:rgb(175,55,130)"><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#cd7923">print</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">(</span><span style="font-variant-ligatures:no-common-ligatures">"Real date: \(date)"</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> )</span></div><div style="margin:0px;line-height:normal;color:rgb(208,59,255)"><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">return</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#cd7923">date</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"> }</span></div><div style="margin:0px;line-height:normal;color:rgb(208,59,255)"><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">return</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#cd7923">nil</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;line-height:normal;min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;line-height:normal;color:rgb(175,55,130)"><span style="font-variant-ligatures:no-common-ligatures;color:#d03bff">var</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#cd7923">date</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> = </span><span style="font-variant-ligatures:no-common-ligatures;color:#cd7923">dateConv</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">(</span><span style="font-variant-ligatures:no-common-ligatures">"Jan 25 20:10"</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">)</span></div><div style="margin:0px;line-height:normal;color:rgb(175,55,130)"><span style="font-variant-ligatures:no-common-ligatures;color:#d03bff">var</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#cd7923">date2</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> = </span><span style="font-variant-ligatures:no-common-ligatures;color:#cd7923">dateConv</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">(</span><span style="font-variant-ligatures:no-common-ligatures">"Jan 25 20:11”</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000">)</span></div><div style="margin:0px;line-height:normal;color:rgb(175,55,130)"><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><br></div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px"><div style="margin:0px;font-size:14px;line-height:normal;font-family:Menlo"><br></div></div></div></div></div></blockquote><br></span>Check out your parentheses. The last one is a right curly quote not the straight ascii quote that it should be.</div><div><br></div></div><br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>