Re: Dual Purpose Applet Question
Re: Dual Purpose Applet Question
- Subject: Re: Dual Purpose Applet Question
- From: Sun Real <email@hidden>
- Date: Wed, 6 Dec 2000 15:19:09 +1100
On Tue, 05 Dec 2000 11:44:04 -0800, Paul Berkowitz <email@hidden>
wrote:
>
On 12/5/00 11:26 AM, "Mr Tea" <email@hidden> wrote:
>
Now, if anyone can suggest a neater way of setting 'theName'...
>
set cd to (current date)
>
set theName to "" & (day of cd) & " " & (text 1 thru 3 of ("" & (month
>
of cd))) & " " & (year of cd) & " - " & time string of cd
>
-- "5 Dec 2000 - 11:38:01 AM"
Yikes! Colons and file names don't mix well. ;-} Also, that code will
only work under OS8.6 or higher.
This is a fast way to get a file-name-friendly time string:
on timeStr(theDate)
set {ts, oldDelims, AppleScript's text item delimiters} to ,
{time string of theDate, AppleScript's text item delimiters, ":"}
set tsi to text items of ts
set AppleScript's text item delimiters to "-"
set delimitedTimeString to tsi as string
set AppleScript's text item delimiters to oldDelims
return delimitedTimeString
end timeStr
And this could be used for the rest of it:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- shortAlphaNumericDate -- -- -- -- returns ddMonyy,
calls monthNumber
on shortAlphaNumericDate(theDate) -- pass a date object
set theShortMonthList to {"Jan", "Feb", "Mar", "Apr", "May", ,
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
return text -2 thru -1 of ("0" & theDate's day) & ,
theShortMonthList's item monthNumber(theDate) & ,
text -2 thru -1 of ((year of theDate) as text)
end shortAlphaNumericDate
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- monthNumber -- -- -- -- from Emmanuel Levy --
returns an integer
-- corresponding to the current month; called by the date handlers
on monthNumber(theDate)
copy theDate to dateTemp
set month of dateTemp to January
return (1 + (theDate - dateTemp + 1314864) div 2629728)
end monthNumber
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- --
Cheers,
Richard Morton
-- Great Lies of the Music Business: "This is one of Jimi's old Strats"