Le 2 sept. 2009 à 23:31:05, Christopher Nebel a écrit :
So, I thought that date "6:01" of (current date) was wrong.
It's not. Good news.
Right, that's an old feature called relative dates -- you can specify a time "of" another date object. The time string still has to match the system formatting, of course. A "date" string may contain a date only, time only, or a date and a time.
Looking closer, I discovered that the ref to (current date) is not required:
date "06:01"
gives the same result than
date "06:01" of (current date).
I wish to know Chris Nebel (or Chris Page) opinion about such a behavior.
"Date" strings with only a date or only a time follow the same rules as before: with no time, the time is presumed to be midnight; with no date, the date is presumed to be the current date. Therefore, 'date "6:01"' and 'date "6:01" of (current date)' are equivalent.
The reason 'date "6:01"' worked for Yvan and not Michelle is that she's using the US locale, which uses a 12-hour clock, and therefore the "AM" or "PM" is required. Yvan, however, is using French, which uses a 24-hour clock, so the AM/PM is optional.
Date input is actually somewhat more lenient than the release notes say it is -- there were some changes that made it in shortly before release. For example, the official US format uses a comma between the month-day and the year (e.g., "Sep 2, 2009"), but it will still accept a date string without a comma. In general, though, you should try to match the system format as closely as possible.
One other thing to watch out for is that CFDateFormatter uses different heuristics for interpreting two-digit years, so AppleScript now uses a cut-off of 1950 (that is, "50" is 1950, "49" is 2049), where the older API used a cut-off of 1991.
--Chris Nebel
AppleScript Engineering