Re: Number of days left in the month
Re: Number of days left in the month
- Subject: Re: Number of days left in the month
- From: Paul Skinner <email@hidden>
- Date: Thu, 21 Nov 2002 07:21:55 -0500
On Wednesday, November 20, 2002, at 06:59 PM, Marc K. Myers posted the
low ascii characters...
>
> Date: Wed, 20 Nov 2002 10:21:43 -0700
>
> Subject: Number of days left in the month
>
> From: Michelle Steiner <email@hidden>
>
> To: email@hidden
>
>
snip
>
> on GetDaysInCurrentMonth()
>
> set s to "31"
>
> try
>
> date s
>
> return s
>
> end try
>
> set s to "30"
>
> try
>
> date s
>
> return s
>
> end try
>
> set s to "29"
>
> try
>
> date s
>
> return s
>
> end try
>
> return "28"
>
> end GetDaysInCurrentMonth
>
>
A while back I came up with a similar but slightly more compact way of
>
calculating the remaining days:
>
>
set theDiff to ((((date daysRemaining()) + days) - (current date)) /
>
days) div 1
>
>
on daysRemaining()
>
set lastDay to {"31", "30", "29", "28"}
>
repeat with i in lastDay
>
try
>
date i
>
return i
>
end try
>
end repeat
>
end daysRemaining
Perhaps a better name for that handler might be advised. ;) [1] [2]
[1] Actually, I assume you meant to...
on daysRemaining()
set lastDay to {"31", "30", "29", "28"}
repeat with I in lastDay
try
date I
return ((((date I) + days) - (current date)) / days) div 1
end try
end repeat
end daysRemaining
... but forgot to put it into the handler.
[2] Footnotes are running rampant.
--
Paul Skinner
_______________________________________________
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.