• 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: Days and hours
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Days and hours


  • Subject: Re: Days and hours
  • From: Bernard Azancot <email@hidden>
  • Date: Mon, 17 Oct 2005 12:51:13 +0200


Le 16 oct. 05 à 22:49, Michelle Steiner a écrit :

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.

Thanks a lot, to all of you. I must now check this.

Yours.
BA _______________________________________________
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


References: 
 >Days and hours (From: Bernard AZANCOT <email@hidden>)
 >Re: Days and hours (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: Days and hours
  • Next by Date: Re: Days and hours
  • Previous by thread: Re: Days and hours
  • Next by thread: Re: Days and hours
  • Index(es):
    • Date
    • Thread