2 Replies Latest reply on Jul 19, 2011 4:16 PM by kokorito

    Add days in a date excluding weekend days

    GabrielGPP

      I need to add 7 days a week on the current date excluding Saturday and Sunday because they are not working days, as Flex works with milliseconds would like to know if I canexcuse these days using ActionScript?

        • 1. Re: Add days in a date excluding weekend days
          kokorito Level 4

          if (theDate.day > 0 && theDate.day < 6) weekDay = true;

          1 person found this helpful
          • 2. Re: Add days in a date excluding weekend days
            GabrielGPP Level 1

            Thanks, but I have a function that adds some sort of date in a variable of type Date, would have to do in a while or if this function to disregard the weekends?

             

            public function dateAdd(datepart:String = "", number:Number = 0, date:Date = null):Date {

             

            if (date == null) {

             

            date = new Date();

            }

             

            var returnDate:Date = new Date(date.time);;

             

            switch (datepart.toLowerCase()) {

            case "fullyear":

            case "month":

            case "date":

            case "hours":

            case "minutes":

            case "seconds":

            case "milliseconds":

            returnDate[datepart] += number;

            break;

            default:

             

            break;

            }

            return returnDate;

            }