Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Add 10 working days.


  • From: javascript@xxxxxxxxxx (Andrew Dunn)
  • Subject: [Javascript] Add 10 working days.
  • Date: Wed, 25 Sep 2002 13:36:04 +1000

I made my own solution to the problem, here is the function:

		function addWorkingDays(myDate,days) { //myDate = starting
date, days = no. working days to add.
			var temp_date = new Date();
			var i = 0;
			var days_to_add = 0;
			while (i < (days)){
				temp_date = new Date(myDate.getTime() +
(days_to_add*24*60*60*1000));
				//0 = Sunday, 6 = Saturday, if the date not
equals a weekend day then increase by 1
				if ((temp_date.getDay() != 0) &&
(temp_date.getDay() != 6)){
					i+=1;
				}
				days_to_add += 1;
			}
			return new Date(myDate.getTime() +
days_to_add*24*60*60*1000);
		}



-----Original Message-----
From: BEKIM BACAJ [mailto:trojani2000@xxxxxxxxxxx] 
Sent: Wednesday, 25 September 2002 11:40 AM
To: javascript@xxxxxxxxxx
Subject: Re: [Javascript] Add 10 working days.


If I understood the problem correctly, you have to extract the weekends or 
ad the number of days that fallitno the weekend of this 10 day prolongation.

The number wary from 2 - 4 so you have to find out what day of the week the 
user entered the textbox so you can decide how many days to add. (hollyday 
date may also cause some additional probs)
this would be all for now. Cheers!


>From: Andrew Dunn <andrew@xxxxxxxxxx>
>Reply-To: javascript@xxxxxxxxxx
>To: "'javascript@xxxxxxxxxx'" <javascript@xxxxxxxxxx>
>Subject: [Javascript] Add 10 working days.
>Date: Wed, 25 Sep 2002 11:13:04 +1000
>
>I need to add 10 working days to a date the user enters in to a text 
>box.
>At
>the moment I'm using this function:
>
>function addDays(myDate,days) {
>			return new Date(myDate.getTime() +
>days*24*60*60*1000);
>		}
>
>This adds the number of days, but it doesn't exclude weekends. Anyone 
>have any suggestions for this?
>
>Thanks.
>_______________________________________________
>Javascript mailing list
>Javascript@xxxxxxxxxx 
>https://lists.LaTech.edu/mailman/listinfo/javascript




_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail. 
http://www.hotmail.com

_______________________________________________
Javascript mailing list
Javascript@xxxxxxxxxx https://lists.LaTech.edu/mailman/listinfo/javascript