Hello there, I am trying to write a function that I can pass a date to that will return the value of 5 working days in the future for a delivery.
I am going about this by creating a bunch of arrays like this
var weekArr:Array = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
"Sun");
var monthDaysArr:Array = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var monthDaysLeapArr:Array = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
and then a big function with lots of if statements that starts like this:
var standardDeliv:Number= 7//number of days for delivery
function checkDeliv(day:String, date:Number, month:String, year:Number):Array{
if([EMAIL="day!="]day!=[/EMAIL]Sat"|| day!="Sun" && date<=21)
deliveryArr[0]=day;
deliveryArr[1]=date+standardDeliv;
deliveryArr[2]=month;
deliveryArr[3]=year;
//lots of other if statements to handle other situations below
}
I was wondering if I am going about this the right way or if there is a much simpler way of doing it. I’m not asking anyone to write the code for me (though feel free :)) I’m just after a bit of direction as to how a more experienced Actionscripter would set about this.
Cheers guys,
Hectors
BTW- I am getting the intial date from a PHP file on my server through LoadVars() and I have written the code above on a text editor without Flash so there may be some punctuation errors.