I have to validate that 1) the end Date is not less than the start Date and 2) the difference between the two UTC Dates is not more than 12 months. To do this, I need a monthDifference function:
public static function monthDifference(start:Date, end:Date):int;
Since partial months can be confusing, this is how month differences are supposed to work:
- The month difference between January 1, 2010 and January 31, 2010 is zero (0).
- The month difference between January 31, 2010 and February 1, 2010 is one (1).
- The month difference between January 1, 2010 and February 28, 2010 is one (1).
- The month difference between January 1, 2010 and March 1, 2010 is two (2).
How can I calculate month difference in ActionScript 3.0?