HyperCard 2.x: International Date Formats (8/92)

Does HyperCard 2.1 UK version have the same date format as the U.S.
version?

HyperCard 2.x calls the Script Manager to parse and to format dates
properly. Therefore, as long as you make no assumptions about date formats in your scripts, it shouldn't matter whether UK or Thai or Arabic date formats are
different.

Here's an example of making bad assumptions about dates: if you want to
know the number of the day of the week of a certain date, you could write a
script that assumes that the date is in the form

Day_Of_Week, Month Day_of_Month, Year

This script could extract word 1 of this date and translate it into
numerical form by using a large If Then Else statement in HyperTalk. If
word 1 is "Sunday" then put 1 into dayOfWeek, etc. Works great under
restrictive conditions, but not worldwide. Actually, it won't work if the
user enters a date in any other format.

The savvy way to do this is to use the HyperTalk "convert" command to parse
the date.

put field "date" into myLocalVar
convert myLocalVar to dateItems -- will now contain dateItems list
get item 7 of myLocalVar -- number of day of week

If you're concerned about displaying dates in the proper format, you can
store them in a numeric form in a hidden field -- dateItems format or
seconds format will do nicely -- and put them into a visible field and
convert them to human-readable form within a script, perhaps on openCard.

on openCard
lock screen
put field "Date in Seconds" into field "Display Date"
convert field "Display Date" to long date
unlock screen
pass openCard
end openCard

If the user enters a date in a field, you can convert it to numerical form
and store it in a hidden field, perhaps on closeField.

on closeField
put field "User Date" into field "Date in DateItems"
convert field "Date in DateItems" to dateItems
if the result is not empty then -- invalid date
answer "Invalid date." with "OK"
select text of field "User Date" -- user should try again
end if
end closeField

By translating dates back and forth between human-readable forms and
numerical forms for storage, you can guarantee that dates will be displayed
properly and sensibly throughout the world.

This article is adapted from the Claris Tech Info database.
Support Information Services
Published Date: Feb 19, 2012