Re: Conversion of ISO Date String to AppleScript Date
Re: Conversion of ISO Date String to AppleScript Date
- Subject: Re: Conversion of ISO Date String to AppleScript Date
- From: Shane Stanley <email@hidden>
- Date: Mon, 06 Mar 2017 10:42:02 +1100
On 6 Mar 2017, at 9:52 am, has <email@hidden> wrote:
>
> Not that Apple's code doesn't include its own embarrassing share of bugs, flaws, and limitations
It does...
> but given the choice between relying on their ISO8601 parsing code and your (or my) ISO8601 parsing code, it's not even a contest.
Except that what the OP wants parsed is not "canonical" ISO 8601 as defined in your library -- his sample string, and the ones in the comments to his script, don't match the strict rule you use.
He can still provide custom format strings to your lib's "parse date" command, but it seems to me that what he was after is a handler that will work with a *range* of (roughly) ISO 8601-conforming formats -- and that's something neither the Cocoa APIs nor your library provide. So to write code using your libraries to parse the formats he lists, he's still going to have to parse the string on input to see which format string to pass to your handler.
My guess is that that original parsing code is as likely, if not more so, to be a source of bugs as any attempt to parse the date and time values directly. Sure, you have to know about the date glitch -- but using your library he's still going to have to know about Cocoa's date gotchas with locales. Given the other fairly basic requirements *in this case* (in particular, no dealing with time zones), direct parsing strikes me as pragmatically justified.
> (The Date library I wrote just wraps the corresponding Cocoa APIs, which is why I somewhat trust it to do the right thing.)
Except your lib uses systemLocale, when the docs explicitly recommend using the "en_US_POSIX" locale (TN QA1480). I don't know if it makes any difference, but under your "use what they use" principle it seems the wrong thing to do. (As opposed to some other code in this thread, which does use the method Apple recommends.)
> What are you and the rest of the responders trying to achieve
I think they're trying to answer the OP's actual request...
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden