1 Reply Latest reply on Oct 2, 2007 10:50 PM by Gregory Lafrance

    How many dates are in each month?

    XXIlladelphia
      Is there an easy way to determine how many dates are in each month?

      as of right now I am looping through creating a new Date() and when the month changes I know the last date of the month.

      This is kind of slow, and building a switch statement would be kind of exhaustive.

      Any ideas?
        • 1. Re: How many dates are in each month?
          Gregory Lafrance Level 6
          This method is created from the same named method in mx.controls.CalendarLayout:

          private function getNumberOfDaysInMonth(year:int, month:int):int{
          var n:int;
          if (month == 1) {
          if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
          n = 29;
          else
          n = 28;
          }
          else if (month == 3 || month == 5 || month == 8 || month == 10)
          n = 30;
          else
          n = 31;
          return n;
          }