<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">The definition should be;</div><div class="">NSString * const kCFCalendarIdentifierISO8601 = @"iso8601”;</div><div class=""><br class=""></div><div class="">It was likely empty since it was probably un-implemented.</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 4, 2016, at 8:34 AM, Pushkar N Kulkarni via swift-corelibs-dev <<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><font face="Verdana,Arial,Helvetica,sans-serif" size="2" class="">Hi Alex, <br class=""><br class="">Thanks for your response. <br class=""><br class="">This failure doesn't happen with ISO8601 alone. There are half a dozen identifiers that aren't supported. Having said that, I added these identifiers to that if-statement and the calendar initialization did happen:<br class=""><br class="">.indian, .islamicTabular, .islamicUmmAlQura, .iso8601, .persian, .republicOfChina<br class=""><br class="">I am not sure if they would cause any other problems thought. <br class=""><br class="">Another thing I got curious about: Why is NSCalendar.Identifier.ISO8601 associated with an empty string here (it doesn't really matter, I guess)?<br class=""><a target="_blank" href="https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSCalendar.swift#L56" class="">https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSCalendar.swift#L56</a><br class=""><br class=""><span class=""><font face="Verdana,Arial,Helvetica,sans-serif" size="2" class=""><font class=""><font class=""><div class="socmaildefaultfont" dir="ltr"><div class="socmaildefaultfont" dir="ltr"><div class="socmaildefaultfont" dir="ltr"><div dir="ltr" style="font-style: normal;" class=""><br class=""><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif" class="">Pushkar N Kulkarni,</font></div>
<div dir="ltr" style="font-style: normal;" class=""><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif" class="">IBM Runtimes</font></div><div dir="ltr" style="font-style: normal;" class=""><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif" class=""><br class=""></font></div><div dir="ltr" class=""><font face="serif, Times New Roman, Times, serif" class=""><i class="">Simplicity is prerequisite for reliability - Edsger W. Dijkstra</i></font></div>
<div dir="ltr" style="font-style: normal; font-size: 10.5pt; font-family: Arial;" class=""><br class=""></div></div></div></div></font></font></font></span><br class=""><br class=""><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2" class=""><font color="#990099" class=""><a target="_blank" href="mailto:-----alblue@apple.com" class="">-----alblue@apple.com</a> wrote: -----</font><div class="iNotesHistory" style="padding-left:5px;"><div style="padding-right:0px;padding-left:5px;border-left:solid black 2px;" class="">To: Pushkar N Kulkarni/India/IBM@IBMIN<br class="">From: Alex Blewitt <alblue@apple.com class=""><br class="">Sent by: <a target="_blank" href="mailto:alblue@apple.com" class="">alblue@apple.com</a><br class="">Date: 10/04/2016 03:28PM<br class="">Cc: swift-corelibs-dev <<a target="_blank" href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>><br class="">Subject: Re: [swift-corelibs-dev] Calendar identifiers<br class=""><br class=""><!--Notes ACF
<meta http-equiv="Content-Type" content="text/html charset=utf8">--><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 4 Oct 2016, at 10:29, Pushkar N Kulkarni via swift-corelibs-dev <<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><font class="" face="Verdana,Arial,Helvetica,sans-serif" size="2">Hi there, <div class=""><br class=""></div><div class="">I've hit an obstacle while working on a crash seen in initing a Calendar (<a href="https://bugs.swift.org/browse/SR-2551)" target="_blank" class="">https://bugs.swift.org/browse/SR-2551)</a><br class=""><font class="" face="Verdana,Arial,Helvetica,sans-serif" size="2"><font class=""><font class=""><div class="socmaildefaultfont" dir="ltr"><div class="socmaildefaultfont" dir="ltr"><div class="socmaildefaultfont" dir="ltr"><div dir="ltr" style="font-style: normal;" class=""><br class=""></div><div dir="ltr" style="font-style: normal;" class="">For the Calendar initialiser "<span class="syntax-keyword" style="box-sizing: inherit; font-family: Menlo, monospace; font-size: 14px; text-indent: -23.111167907714844px;"><font class="" color="#aa0d91">init</font></span><span style="font-family: Menlo, monospace; font-size: 14px; text-indent: -23.111167907714844px; background-color: rgb(249, 250, 250);" class=""><font class="" color="#333333">(</font></span><span class="syntax-identifier" style="box-sizing: inherit; font-family: Menlo, monospace; font-size: 14px; text-indent: -23.111167907714844px;">identifier</span><span style="font-family: Menlo, monospace; font-size: 14px; text-indent: -23.111167907714844px; background-color: rgb(249, 250, 250);" class=""><font class="" color="#333333">: </font></span><span class="syntax-type" style="box-sizing: inherit; font-family: Menlo, monospace; font-size: 14px; text-indent: -23.111167907714844px;"><font class="" color="#5c2699">Calendar</font></span><span style="font-family: Menlo, monospace; font-size: 14px; text-indent: -23.111167907714844px; background-color: rgb(249, 250, 250);" class=""><font class="" color="#333333">.</font></span><span class="syntax-type" style="box-sizing: inherit; font-family: Menlo, monospace; font-size: 14px; text-indent: -23.111167907714844px;"><font class="" color="#5c2699">Identifier</font></span><span class="syntax-type" style="box-sizing: inherit; font-family: Menlo, monospace; font-size: 14px; text-indent: -23.111167907714844px; background-color: rgb(249, 250, 250);"><font class="" color="#333333">)", </font></span>the possible values of Calendar.Identifier are listed <a target="_blank" href="https://developer.apple.com/reference/foundation/calendar.identifier" title="https://developer.apple.com/reference/foundation/calendar.identifier" class="">here</a>. However, we eventually end up calling "<span class="pl-en" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;"><font class="" color="#795da3">_CFCalendarInitWithIdentifier</font></span><span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;" class=""><font class="" color="#333333">(</font></span><span class="pl-c1" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;"><font class="" color="#0086b3">CFCalendarRef</font></span><span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;" class=""><font class="" color="#333333"> calendar, </font></span><span class="pl-c1" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;"><font class="" color="#0086b3">CFStringRef</font></span><span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;" class=""><font class="" color="#333333"> identifier)" </font></span>and the latter works only for a specific set of calendar identifiers. See this if statement:</div><div dir="ltr" style="font-style: normal;" class=""> <a href="https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/Locale.subproj/CFCalendar.c#L239" target="_blank" class="">https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/Locale.subproj/CFCalendar.c#L239</a><br class=""></div><div dir="ltr" style="font-style: normal;" class=""><br class=""></div><div dir="ltr" style="font-style: normal;" class="">For other identifier values, we crash (that is SR-2551). On mac, all the identifier values are supported. It seems that the calendar identifier is ultimately encoded as a key-value pair in the locale ID for the calendar. </div><div dir="ltr" style="font-style: normal;" class=""><br class=""></div><div dir="ltr" style="font-style: normal;" class="">Can anybody please help me understand the rationale of the if-statement above? I am new to ICU. I did search for justifications but didn't come across convincing. <br class=""></div></div></div></div></font></font></font></div></font></div></blockquote><br class=""></div><div class="">The if statement is canonicalising the reference to the constant e.g. kCFCalendarIdentifierBuddhist. This allows other instances to be passed in but then resolved to the same instance, such that pointer comparisons work for future calls. The same is done for Swift.</div><div class=""><br class=""></div><div class="">On macOS, there are additional checks in the CoreFoundation equivalent (such as kCFCalendarIdentifierISO8601) which is why it works on Darwin. However, I don't know if there were specific reasons for excluding the ISO8601 calendar, unless the ICU library doesn't understand it. Testing adding support should be a case of doing something similar to this commit, which re-enabled the Chinese calendar:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift-corelibs-foundation/commit/c1d940dd6099de65f959fd42274cf0e65984efe0" class="">https://github.com/apple/swift-corelibs-foundation/commit/c1d940dd6099de65f959fd42274cf0e65984efe0</a></div><br class=""><div class="">Of course building with the 'if' switch enabled may highlight other issues, but on a quick test build it seems that adding the additional if case to the statement results in the ISO8601 calendar being returned. I'll let others explain in more detail if there's some specific subtlety for why it was left out in the first place.</div><div class=""><br class=""></div><div class="">Alex</div></alblue@apple.com></div></div></font></font><br class="">
_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev<br class=""></div></blockquote></div><br class=""></body></html>