Shane,
Many thanks for you review and critique of my date handler.
Please see my responses below.
Best Regards,
Jim Underwood
aka JMichaelTX
From: Shane Stanley < email@hidden>
Date: Sun, Mar 5, 2017 at 5:55 AM
To: "ASUL (AppleScript)" < email@hidden>
Subject: Re: Conversion of ISO Date String to AppleScript Date
On 5 Mar 2017, at 5:57 pm, Jim Underwood < email@hidden> wrote:
please try to shoot holes in this script.
To be picky, you talk about "ISO dates", by which you presumably mean ISO 8601 dates. And you only handle a small subset
Yes, I meant ISO 8601, but only in a very limited manner. As I stated in my script comments, I am NOT attempting to handle time zone offsets. My script is intended to work only with local time zone.
• pDateStr | text | Date String in ISO format
Assumes local time zone
If time is included, assumed to be 24-HR format
(and I think you're actually venturing outside ISO 8601 with the space instead of a T -- that's more RFC 3339), which is fine. But you're not trapping for the other possibilities.
Actually, my script works equally well with either a "T" or a SPACE between the date and time.
It looks for the data by position, not by delimiter.
As I stated in my script comments:
like any of these:
2016-01-05
2016-01-05 13:01:15
2016-01-05T13:01:15
So if you get a string like "2016-01-05T13:01:15Z", rather than erroring, you're going to return a potentially erroneous date. Perhaps you should also test for a maximum length, at least.
That is an excellent point. Thank you.
I will add additional data validation to check for any characters that indicate time zone.
--
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
|