Re: Need help with finding first of the month
Re: Need help with finding first of the month
- Subject: Re: Need help with finding first of the month
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 01 Jul 2004 14:00:22 -0700
On 7/1/04 1:00 PM, "Young, Rich A." <email@hidden> wrote:
>
I need to add a piece to an existing script that will find how many days it
>
is until the first day of the next month from any given date taking into
>
account things like leap year. Can anyone point me in the right direction
I'm going to assume that you don't care about the exact time - so any time
on the 25th of a 30-day month will return "6 days" to the 1st of the next
month whether you're asking at midnight or at 10 pm. The version here is for
OS 9 and later.
set today to (current date)
set time of today to 0 -- midnight
set thisMonth to month of today
copy today to nextMonth
set monthList to {January, February, March, April, May, June, July,
August, September, October, November, December}
repeat with i from 1 to 12
if thisMonth = item i of monthList then
if i /= 12 then
set month of nextMonth to item (i + 1) of monthList
else
set month of nextMonth to January
set year of nextMonth to (year of today) + 1
end if
exit repeat
end if
end repeat
set diff to (nextMonth - today) / days as integer
--
Paul Berkowitz
_______________________________________________
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.