• 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: Deivy Marck Petrescu <email@hidden>
  • Date: Fri, 5 Feb 2010 10:53:13 -0500


On Feb 5, 2010, at 7:00 AM, Mark J. Reed wrote:

On Fri, Feb 5, 2010 at 6:43 AM, Nigel Garvey
<email@hidden> wrote:

Obviously we all had to make our own decisions about what to do if
either of the input dates was a Saturday or a Sunday. I posted the
various script results to help Bert and for the interest of the other
contributors. Sorry if I seemed to imply any criticism.

Absolutely not!  I'm sorry if my post came off as defensive; I didn't
take your post as critical.  I was just trying to provide a standard
against which to compare the results you compiled.

Yes. I noticed the upward rounding myself, but since Bert's script made
no attempt to convert 'days' as 24-hour periods to days as calendar
entities, I didn't see the point of it and decided to ignore it.

FWIW, looking around at the various algorithms on the net and the
NETWORKDAYS function in Excel (which I can't help but read as "network
days" instead of "net workdays"), inclusive counting is the norm.
From a workday to itself is one day, not zero.

Also, the problem is usually cast as counting the number of business
days between two dates (inclusive of those dates), which answers the
question of what to do when starting or ending on a weekend.  Simply
start counting with the first business day *on or after* the first
date, and stop counting with the last business day *on or before* the
last date.  My list of manually-counted answers used that method, and
so is more correct than the answers produced by my coded solution.

--
Mark J. Reed <email@hidden>

In view of these enlightening discussions, I changed the script a bit.
I do not know how much sense it makes, but apparently it will now conform to a standard.
So, if current date is either a Saturday or Sunday, it will be moved to Monday.
It doesn't make much sense to me, but at the same time it does ???

So here is the new script:


<script>
tell application "Finder"
set l to contents of item 1 of (get selection)
set M to (get modification date of l)
end tell
set D to ((current date))
set AGE_INFO to (D - M) div (days)

on correct_AGE_INFO(AGE_INFO, D, M)


set dwi to weekday of (M) as integer
set dwf to weekday of D as integer
if (dwf mod 6 = 1) then set {AGE_INFO, dwf} to {AGE_INFO + 2 - (dwf mod 7), 2}
set ewend to 0
if (dwf - dwi) < 0 or (dwf - dwi) = 6 then if (dwi mod 6 = 1) then
set ewend to 0.5
else
set ewend to 1
end if
return (AGE_INFO - 2 * (AGE_INFO div 7) - 2 * ewend) div 1


end correct_AGE_INFO

</script>

 
Deivy Petrescu
email@hidden



 _______________________________________________
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

  • Follow-Ups:
    • Re: Correcting AGE_INFO
      • From: "Mark J. Reed" <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>)

  • Prev by Date: Re: New date bug [Re: Correcting AGE_INFO]
  • Next by Date: Re: Script Menu in 10.6.2
  • Previous by thread: Re: Correcting AGE_INFO
  • Next by thread: Re: Correcting AGE_INFO
  • Index(es):
    • Date
    • Thread