Re: Days and hours
Re: Days and hours
- Subject: Re: Days and hours
- From: Michelle Steiner <email@hidden>
- Date: Sun, 16 Oct 2005 13:49:08 -0700
On Oct 16, 2005, at 12:54 PM, Bernard AZANCOT wrote:
I would like to know how to calculate the number of work hours to
pay to a person working for me, in a given month, knowing that each
Monday -> 2,5 h.
Tuesday -> 2,5 h.
Wednesday -> 2 h.
Friday
This should do it.
set hrs to 0
set working_month to current date
set mon to (choose from list {January, February, March, April, May,
June, July, August, September, October, November, December} with
title "Employment month" with prompt "Enter the month for which you
wish to compute hours worked." default items {month of working_month})
try
set mon to item 1 of mon
on error
error number -128
end try
-- the try block checks for the user clicking cancel.
if mon is less than month of working_month then set year of
working_month to (year of working_month) - 1
-- If the month selected is less than the current month, then it was
selected for the previous year; adjust the year accordingly.
set month of working_month to mon
repeat with i from 1 to 31
set day of working_month to i
set thisday to weekday of working_month
if month of working_month is not mon then exit repeat
--the only way this will happen is if you go past the number of days
in the month; i.e., to the 31st of a 30 day month or to Feb 29th (or
Feb 30 of a leap year), so bail out of the loop.
if thisday is Monday or thisday is Tuesday then
set hrs to hrs + 2.5
else if thisday is Friday then
set hrs to hrs + 2
end if
end repeat
display dialog hrs
--
Give Peace A Chance.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden