Re: Help with validating a date input to a dialog
Re: Help with validating a date input to a dialog
- Subject: Re: Help with validating a date input to a dialog
- From: Victor Yee <email@hidden>
- Date: Sat, 31 Mar 2001 02:55:45 -0500
On Fri, 30 Mar 2001 18:46:22 -0800, Paul Berkowitz wrote,
>
1) On a user's machine which has a different format in Date & Time control
>
panel (precisely the sort of user who will want to enter in a different
>
format such as dd/mm/yyyy), the script will do exactly the opposite of what
>
you want: it will error when the format is different from the user's.
Here's a test for the system date format:
on testSystemDateFormat()
set testList to {"20/01/2001", "01/20/2001", "2001/20/01", "2001/01/20"}
set resultList to {"dd/mm/yyyy", "mm/dd/yyyy", "yyyy/dd/mm", "yyyy/mm/dd"}
repeat with i from 1 to 4
try
date (contents of testList's item i)
return contents of resultList's item i
on error
--do nothing
end try
end repeat
end testSystemDateFormat
Note that the key is to have the day in the test string be greater than 12 and the year greater than 31.
Victor