• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Conversion of ISO Date String to AppleScript Date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Conversion of ISO Date String to AppleScript Date
      • From: Jim Underwood <email@hidden>
References: 
 >Re: Conversion of ISO Date String to AppleScript Date (From: has <email@hidden>)
 >Re: Conversion of ISO Date String to AppleScript Date (From: "Stockly, Ed" <email@hidden>)
 >Re: Conversion of ISO Date String to AppleScript Date (From: has <email@hidden>)

  • Prev by Date: Re: Conversion of ISO Date String to AppleScript Date
  • Next by Date: Re: Scripting Better Applescript support requests !
  • Previous by thread: Re: Conversion of ISO Date String to AppleScript Date
  • Next by thread: Re: Conversion of ISO Date String to AppleScript Date
  • Index(es):
    • Date
    • Thread