Re: Correcting AGE_INFO
Re: Correcting AGE_INFO
- Subject: Re: Correcting AGE_INFO
- From: Deivy Marck Petrescu <email@hidden>
- Date: Thu, 4 Feb 2010 11:28:18 -0500
On Feb 4, 2010, at 4:43 AM, Bert Groeneveld wrote: set D to current date tell application "Finder" set M to modification date of alias myFile -- myFile was of course set to some file earlier in the script end tell set AGE_INFO to round (D - M) / days rounding up -- is always an integer set AGE_INFO to correct_AGE_INFO(AGE_INFO, D, M)
on correct_AGE_INFO(AGE_INFO, D, M) -- what to put here? (as less code as possible, of course) end correct_AGE_INFO
Hello, I'm breaking my head about finding some "super algorythm" for this: I want to correct AGE_INFO, by omitting the days of the weekend (saturday and sunday) Three possible examples (among many others): If the weekday of D is thursday and the weekday of M is friday and AGE_INFO is 7, then I want to correct AGE_INFO by -2 (one weekend in between) If the weekday of D is tuesday and the weekday of M is friday and AGE_INFO is 12, then I want to correct AGE_INFO by -4 (2 weekends) If the weekday of D is wednesday and the weekday of M is monday and AGE_INFO is 3, then I want to do nothing.
Thanks in advance for any help,
Bert.
Bert, try this but make the corrections for age-info. Also, it is kind of difficult to consider what would you do if either first or last day is a weekend day. It is not clear what to consider.
set AGE_INFO to (D - M) div (days) correct_AGE_INFO(AGE_INFO, D, M)
on correct_AGE_INFO(AGE_INFO, D, M)
set dw to weekday of (M) as integer set dw1 to weekday of D as integer set ewend to 0 if (dw1 - dw) < 0 or (dw1 - dw) = 6 then if dw1 = 1 or dw = 1 then set ewend to 0.5 else set ewend to 1 end if return AGE_INFO - 2 * (AGE_INFO div 7) - 2 * ewend
end correct_AGE_INFO
|
_______________________________________________
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