• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Correcting AGE_INFO
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correcting AGE_INFO


  • Subject: Re: Correcting AGE_INFO
  • From: "email@hidden" <email@hidden>
  • Date: Fri, 5 Feb 2010 13:28:17 -0800

>>>That's demonstrably correct, but as I said, inefficient. So the goal is to achieve the same results without having to iterate
over all the days in between.

Not sure if that's always a worthy goal.

The difference in efficiency is pretty minor.  Plus a solution that iterates is pretty easily modified to include a list of dates that should be excluded for holidays, and such, if needed. (I can't imagine a practical use where that's not needed).

 ES

------------
property holidayList : {}
set holidayList to {"12/25/09", "1/1/10", "7/4/10"} -- user can add more dates
repeat with x from 1 to count of holidayList
	set item x of holidayList to date (item x of holidayList)
end repeat
set startDate to date ("11 - 20 - 2009")
set endDate to date ("1 - 2 - 2010")

set BD to CountBusinessDays(startDate, endDate)

on CountBusinessDays(aDate, endDate)
	set dayCount to 0
	repeat until aDate > endDate
		if aDate is not in holidayList and weekday of aDate is not in {Saturday, Sunday} then set dayCount to dayCount + 1
		set aDate to (aDate + 1 * days)
	end repeat
	return dayCount
end CountBusinessDays

-------------


On Feb 5, 2010, at 11:20am, Mark J. Reed wrote:

> That's demonstrably correct, but as I said, inefficient.
> So the goal is to achieve the same results without having to iterate
> over all the days in between.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Correcting AGE_INFO (From: "Nigel Garvey" <email@hidden>)
 >Re: Correcting AGE_INFO (From: "Mark J. Reed" <email@hidden>)
 >Re: Correcting AGE_INFO (From: "Nigel Garvey" <email@hidden>)
 >Re: Correcting AGE_INFO (From: "Mark J. Reed" <email@hidden>)
 >Re: Correcting AGE_INFO (From: Deivy Marck Petrescu <email@hidden>)
 >Re: Correcting AGE_INFO (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Correcting AGE_INFO
  • Next by Date: Re: Correcting AGE_INFO
  • Previous by thread: Re: Correcting AGE_INFO
  • Next by thread: Re: Correcting AGE_INFO
  • Index(es):
    • Date
    • Thread