GetDate XObject for Mac
Detects the date regardless of local date settings
The GetDate XObject allows you to detect the current date in a standard
format that does not depend on the user's local date format settings.
This is useful when you must deliver a Director piece that can be used
with different languages and countries. Director's built-in date
features return different results with different countries or
date format settings.
GetDate returns an integer in the format
YYYYMMDD (i.e., 19971225 for Christmas this year).
This format is known as the ANSI date, and can be
meaningfully compared to previous or future dates
numerically, with Lingo's '<' or '>' operators.
The GetDate XObject for the Mac is freeware, and was written to
exactly match the syntax
of Tab Julius' freeware GetDate XObject for Windows (see the
Penworks site for that).
Penworks also has another date utility Xtra which
can report elapsed time between any two dates, and has other
useful features.
The GetDate XObject for the Mac is also distributed for free by
g/matter, inc. (formerly known as
'gray matter design') in San Francisco.
Since GetDate was created, Darryl Plant of
Moshofsky/Plant Creative Services has published
a Lingo-only
solution for getting international date information within Director.
This is useful from Shockwave Director movies, because there's
no need for the user to download an XObject for their browser plug-in
support folder. The Lingo scripting looks like this...
To derive the year: "set aYear = the year of internationalDate ()"
To derive the month: "set aMonth = the month of internationalDate ()"
To derive the day: "set aDay = the day of internationalDate ()"
on internationalDate
set IDate = [:]
set aDate = the short date
set dateLength = the number of chars of aDate
set sDate = []
set aNum = ""
repeat with i = 1 to dateLength
set aChar = char i of aDate
set aSCII = charToNum (aChar)
if (aSCII < 48) or (aSCII > 57) then
if aNum = "" then nothing
else
add sDate, (value (aNum) mod 100)
set aNum = ""
end if
else
set aNum = aNum & aChar
if i = dateLength then add sDate, (value (aNum) mod 100)
end if
end repeat
set aDate = the abbreviated date
set dateLength = the length of aDate
set abbDate = []
set aNum = ""
repeat with i = 1 to dateLength
set aChar = char i of aDate
set aSCII = charToNum (aChar)
if (aSCII < 48) or (aSCII > 57) then
if aNum = "" then nothing
else
add abbDate, (value (aNum) mod 100)
set aNum = ""
end if
else
set aNum = aNum & aChar
if i = dateLength then add abbDate, (value (aNum) mod 100)
end if
end repeat
set year = getAt (abbDate, 2)
set day = getAt (abbDate, 1)
set whereYear = getOne (sDate, year)
addProp IDate, #year, value (year)
deleteAt sDate, whereYear
set whereDay = getOne (sDate, day)
addProp IDate, #day, value (day)
deleteAt sDate, whereDay
addProp IDate, #month, value (getAt (sDate, 1))
return Idate
end
The GetDate XObject is still useful if you've already coded
a project with the Windows GetDate XObject and want a quick
Macintosh port. The XObject solution
is also pretty well tested at this point and speaks directly to
the underlying operating systems APIs, without depending on the implementation
of Director's Lingo date functions. And you can't argue with the price!
A demo movie is enclosed with the GetDate XObject which
demonstrates the use of the plug-in. The demo movie is
in Director 4 format, but can be opened and used without
modification in Director 5. The demo movie contains a script
castmember with cut-n-paste Lingo handlers, to get you up and
running immediately.
I'd appreciate a note from you
if you pick up a copy of GetDate here. I'll
keep you informed of updates. Email me at
gpicher@maine.com.
The .sit.hqx format is standard for Mac shareware distribution,
and can be decompressed with
Stuffit Expander for the Mac. You should be
able to download this Mac XObject even using a PC (decompressing the .hqx or
.sit file on a Mac).

Glenn M. Picher: Dirigo Multimedia
Back to Glenn's home page