Re: Repaying help by posting small Applescripts
Re: Repaying help by posting small Applescripts
- Subject: Re: Repaying help by posting small Applescripts
- From: Christopher Stone <email@hidden>
- Date: Fri, 30 Apr 2004 07:14:55 -0500
At 04:58 -0400 04/30/2004, Graff wrought:
Your convertMonthToInteger function works fine but here's an alternative
that does the same job and does it with less clutter in your script:
Jaguar can now do the direct coercion:
on dateToInt(theDate)
tell theDate
set m to it's month as integer
if m < 10 then set m to "0" & m
end tell
end dateToInt
set d to date "Thursday, May 04, 1961 11:40:00"
dateToInt(d)
--> 05
More general:
-- Swiped from Emmanuel Levy
on MonthIndexFromDate(theDate)
copy theDate to theOtherDate
set month of theOtherDate to January
1 + (theDate - theOtherDate) div (28 * days)
if result < 10 then "0" & result
end MonthIndexFromDate
set d to date "Thursday, May 04, 1961 11:40:00"
MonthIndexFromDate(d)
--> 05
Chris
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.