Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Repaying help by posting small Applescripts



Christopher Stone wrote on Fri, 30 Apr 2004 07:14:55 -0500:

>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

Of course, that returns a string for months up to September and no result
otherwise, so for consistency:

on MonthIndexFromDate(theDate)
copy theDate to theOtherDate
set month of theOtherDate to January
(theOtherDate - 252500000 - theDate) div -2500000 as string -- :-)
return text 2 thru 3 of result
end MonthIndexFromDate


NG
_______________________________________________
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.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.