Hi Jim, 

(I just trying put up a post, but it doesnt look it went, so im resending 
it...sorry if it goes up twice)

I'm having trouble with the add() function.  I got the diff() function to work 
correctly, but it seems like there might be a bug with the add() function 
(unless i'm doing something wrong, which could be the case haha).  i'm trying 
to add 5 days to today's date (9/27/06).  Only business days should make the 
new date be Wednesday, Oct 4.  But instead it says monday, Oct 2.  So it seems 
that it still is counting weekends.  If I put in to add 6 days however, the 
function works correctly.  It seems that it still counts the weekends when you 
add certain amounts of days.  Do you have any idea how this could be fixed?

var numberOfDaysToAdd = 5
var mydate = new Date()
document.write("<br>"+mydate+"<br><br>")
mydate.add(numberOfDaysToAdd, "businessdays", true);
document.write(mydate)

Thanks for the help, Jon


>> -----Original Message-----
>
>My Date Extension Library does this.
>
>http://www.depressedpress.com/Content/Development/JavaScript/Extensions/DP_D
>ateExtensions/Index.cfm
>
>Both the "add()" and "diff()" methods support "businessdays" as a DatePart
>which should (if they're no bugs) do what you want.
>
>After importing the library your sample code would become:
>
>var numberOfDaysToAdd = 5
>var mydate1 = new Date(2006,9,26)
>mydate1.add(numberOfDaysToAdd, "businessdays", true);
>
>Note that the "true" at the end is needed to change the date "in place" (a
>destructive operation).  If left out (or false) the function would not
>change the original date but would rather return the new date as in:
>
>myNewDate = mydate1.add(numberOfDaysToAdd, "businessdays");
>
>The library also provides CF-like dateFormat(), timeFormat() and compare()
>functions as well as support for common ISO8601 dates.
>
>Hope this helps.
>
>Jim Davis

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/Javascript/message.cfm/messageid:3226
Subscription: http://www.houseoffusion.com/groups/Javascript/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.33

Reply via email to